summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bragi.nix55
1 files changed, 54 insertions, 1 deletions
diff --git a/bragi.nix b/bragi.nix
index 3b634767..2cb560d9 100644
--- a/bragi.nix
+++ b/bragi.nix
@@ -33,6 +33,9 @@ in rec {
33 inherit 33 inherit
34 (lib.mapAttrs (name: oldPkgs.haskell.lib.dontCheck) super) 34 (lib.mapAttrs (name: oldPkgs.haskell.lib.dontCheck) super)
35 Glob filelock; 35 Glob filelock;
36 inherit
37 (self.callPackage ./custom/thermoprint { inherit (self) Glob; inherit (pkgs) runCommand makeWrapper; extraPackages = (p: with p; [ persistent-postgresql ]); })
38 thermoprint-spec thermoprint-bbcode thermoprint-client thermoprint-server thermoprint-webgui tprint bbcode;
36 }; 39 };
37 }; 40 };
38 41
@@ -40,7 +43,7 @@ in rec {
40 43
41 mpd = oldPkgs.mpd.override { gmeSupport = false; pulseaudioSupport = false; }; 44 mpd = oldPkgs.mpd.override { gmeSupport = false; pulseaudioSupport = false; };
42 45
43 inherit (haskellPackages) trivmix; 46 inherit (haskellPackages) trivmix thermoprint-server thermoprint-webgui tprint;
44 }; 47 };
45 48
46 nixpkgs.config.allowUnfree = true; 49 nixpkgs.config.allowUnfree = true;
@@ -312,6 +315,41 @@ in rec {
312 openssh.authorizedKeys.keyFiles = template.openssh.authorizedKeys.keyFiles; 315 openssh.authorizedKeys.keyFiles = template.openssh.authorizedKeys.keyFiles;
313 }; 316 };
314 317
318 users.extraUsers."thermoprint" = {
319 name = "thermoprint";
320 group = "lp";
321 isSystemUser = true;
322 createHome = true;
323 home = "/var/lib/thermoprint";
324 };
325
326 systemd.services."thermoprint" = {
327 environment = {
328 THERMOPRINT_CONFIG = ./bragi/thermoprint-server;
329 THERMOPRINT_CACHE = ''${users.extraUsers."thermoprint".home}/dyre'';
330 };
331 requires = [ "postgresql.service" ];
332 wantedBy = [ "default.target" ];
333 serviceConfig = {
334 Type = "simple";
335 ExecStart = ''${pkgs.thermoprint-server}/bin/thermoprint-server --force-reconf'';
336 User = users.extraUsers."thermoprint".name;
337 Group = users.extraUsers."thermoprint".group;
338 WorkingDirectory = "~";
339 };
340 };
341
342 systemd.services."thermoprint-webgui" = {
343 wantedBy = [ "default.target" ];
344 serviceConfig = {
345 Type = "simple";
346 ExecStart = ''${pkgs.thermoprint-webgui}/bin/thermoprint-webgui -P 80 -A localhost -F /thermoprint/api/ -a "localhost" -p 8081'';
347 User = users.extraUsers."thermoprint".name;
348 Group = users.extraUsers."thermoprint".group;
349 WorkingDirectory = "~";
350 };
351 };
352
315 users.extraUsers."bar" = { 353 users.extraUsers."bar" = {
316 name = "bar"; 354 name = "bar";
317 group = "nogroup"; 355 group = "nogroup";
@@ -386,6 +424,17 @@ in rec {
386 listen *:80; 424 listen *:80;
387 server_name _; 425 server_name _;
388 426
427 location /thermoprint/api/ {
428 proxy_pass http://[::1]:8080/;
429 proxy_http_version 1.1;
430 proxy_set_header Upgrade $http_upgrade;
431 proxy_set_header Connection "upgrade";
432 }
433
434 location /thermoprint/ {
435 proxy_pass http://localhost:8081/;
436 }
437
389 location /bar/ { 438 location /bar/ {
390 proxy_pass http://[::1]:8082/; 439 proxy_pass http://[::1]:8082/;
391 } 440 }
@@ -401,6 +450,10 @@ in rec {
401 host all all 10.141.0.0/16 md5 450 host all all 10.141.0.0/16 md5
402 ''; 451 '';
403 initialScript = pkgs.writeText "schema.sql" '' 452 initialScript = pkgs.writeText "schema.sql" ''
453 CREATE USER thermoprint;
454 CREATE DATABASE thermoprint WITH OWNER = thermoprint;
455 GRANT ALL ON DATABASE thermoprint TO thermoprint;
456
404 CREATE USER bar; 457 CREATE USER bar;
405 CREATE DATABASE bar WITH OWNER = bar; 458 CREATE DATABASE bar WITH OWNER = bar;
406 GRANT ALL ON DATABASE bar TO bar; 459 GRANT ALL ON DATABASE bar TO bar;