From 954d0edebd7a3e5cebf93f5053a4b8f18c77feae Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Wed, 26 Feb 2020 20:15:47 -0500 Subject: Update pjournal to a working service --- config/pjournal.nix | 28 +++++++++++----------------- pkgs/pjournal/default.nix | 4 +++- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/config/pjournal.nix b/config/pjournal.nix index b0ac9da..840e72a 100644 --- a/config/pjournal.nix +++ b/config/pjournal.nix @@ -20,7 +20,7 @@ in services.postgresql = { enable = true; - ensureDatabases = ["pjournal" "pjournal_test"]; + ensureDatabases = ["pjournal"]; ensureUsers = [ { name = "pjournal"; @@ -28,31 +28,25 @@ in "DATABASE pjournal" = "ALL PRIVILEGES"; }; } - { - name = "pjournal_test"; - ensurePermissions = { - "DATABASE pjournal_test" = "ALL PRIVILEGES"; - }; - } ]; }; - systemd.services.pjournal-test = { - description = "pjournal test instance"; + systemd.services.pjournal = { + description = "pjournal instance"; after = [ "multi-user.target" "postgresql.service" ]; wantedBy = ["multi-user.target"]; environment = { RUST_BACKTRACE = "1"; }; + script = '' + # This will fail the first time. Run pjournal init to initialize + # the database. + ${cfg.package}/bin/pjournal \ + --database_url postgres://pjournal@/pjournal \ + --port 8080 + ''; serviceConfig = { - ExecStart = '' - # This will fail the first time. Run pjournal init to initialize - # the database. - ${cfg.package}/bin/pjournal \ - --database_url postgres://pjournal_test@/pjournal_test \ - --port 8080 - ''; - User = "pjournal_test"; + User = "pjournal"; }; }; diff --git a/pkgs/pjournal/default.nix b/pkgs/pjournal/default.nix index e2ddf4d..39769c9 100644 --- a/pkgs/pjournal/default.nix +++ b/pkgs/pjournal/default.nix @@ -28,8 +28,10 @@ in rustPlatform.buildRustPackage rec { postInstall = '' mkdir $out/etc/ cp -r templates $out/etc + cp -r static $out/etc wrapProgram "$out/bin/pjournal" \ - --add-flags "--template_path $out/etc/templates" + --add-flags "--template_path $out/etc/templates" \ + --add-flags "--static_path $out/etc/static" ''; preConfigure = '' -- cgit v1.2.3