From c799ec9fe235f37986fb04d8574645421fd51101 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 12 Apr 2018 13:51:50 +0200 Subject: Revert "strip out thermoprint" This reverts commit 805c2616e0256b6ff076dbdf85014bbbb4d72a9a. --- bragi.nix | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/bragi.nix b/bragi.nix index 3b634767..2cb560d9 100644 --- a/bragi.nix +++ b/bragi.nix @@ -33,6 +33,9 @@ in rec { inherit (lib.mapAttrs (name: oldPkgs.haskell.lib.dontCheck) super) Glob filelock; + inherit + (self.callPackage ./custom/thermoprint { inherit (self) Glob; inherit (pkgs) runCommand makeWrapper; extraPackages = (p: with p; [ persistent-postgresql ]); }) + thermoprint-spec thermoprint-bbcode thermoprint-client thermoprint-server thermoprint-webgui tprint bbcode; }; }; @@ -40,7 +43,7 @@ in rec { mpd = oldPkgs.mpd.override { gmeSupport = false; pulseaudioSupport = false; }; - inherit (haskellPackages) trivmix; + inherit (haskellPackages) trivmix thermoprint-server thermoprint-webgui tprint; }; nixpkgs.config.allowUnfree = true; @@ -312,6 +315,41 @@ in rec { openssh.authorizedKeys.keyFiles = template.openssh.authorizedKeys.keyFiles; }; + users.extraUsers."thermoprint" = { + name = "thermoprint"; + group = "lp"; + isSystemUser = true; + createHome = true; + home = "/var/lib/thermoprint"; + }; + + systemd.services."thermoprint" = { + environment = { + THERMOPRINT_CONFIG = ./bragi/thermoprint-server; + THERMOPRINT_CACHE = ''${users.extraUsers."thermoprint".home}/dyre''; + }; + requires = [ "postgresql.service" ]; + wantedBy = [ "default.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = ''${pkgs.thermoprint-server}/bin/thermoprint-server --force-reconf''; + User = users.extraUsers."thermoprint".name; + Group = users.extraUsers."thermoprint".group; + WorkingDirectory = "~"; + }; + }; + + systemd.services."thermoprint-webgui" = { + wantedBy = [ "default.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = ''${pkgs.thermoprint-webgui}/bin/thermoprint-webgui -P 80 -A localhost -F /thermoprint/api/ -a "localhost" -p 8081''; + User = users.extraUsers."thermoprint".name; + Group = users.extraUsers."thermoprint".group; + WorkingDirectory = "~"; + }; + }; + users.extraUsers."bar" = { name = "bar"; group = "nogroup"; @@ -386,6 +424,17 @@ in rec { listen *:80; server_name _; + location /thermoprint/api/ { + proxy_pass http://[::1]:8080/; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /thermoprint/ { + proxy_pass http://localhost:8081/; + } + location /bar/ { proxy_pass http://[::1]:8082/; } @@ -401,6 +450,10 @@ in rec { host all all 10.141.0.0/16 md5 ''; initialScript = pkgs.writeText "schema.sql" '' + CREATE USER thermoprint; + CREATE DATABASE thermoprint WITH OWNER = thermoprint; + GRANT ALL ON DATABASE thermoprint TO thermoprint; + CREATE USER bar; CREATE DATABASE bar WITH OWNER = bar; GRANT ALL ON DATABASE bar TO bar; -- cgit v1.2.3