From 6038aad312ff61d8144fcf61a61a2e72555e5174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 16 Jan 2024 22:59:18 +0200 Subject: [PATCH] fix databasePath --- modules/e11sync/default.nix | 26 ++++++++++++++++---------- pkgs/e11sync-backend.nix | 3 +++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/modules/e11sync/default.nix b/modules/e11sync/default.nix index 428567f..1f6fa17 100644 --- a/modules/e11sync/default.nix +++ b/modules/e11sync/default.nix @@ -18,13 +18,16 @@ e11sync-backend: { type = port; default = 8002; }; + databasePath = lib.mkOption { + type = path; + default = "/var/lib/e11sync-backend/db.sqlite3"; + }; }; config = let cfg = config.e11sync; pkg-backend = e11sync-backend.override { - inherit (cfg) backendPort; - databasePath = "/var/lib/e11sync/db.sqlite3"; + inherit (cfg) backendPort databasePath; }; in lib.mkIf cfg.enable { @@ -36,11 +39,13 @@ e11sync-backend: { e11sync-backend = { description = "e11sync backend"; environment = lib.mkMerge [ - {TZ = "UTC";} - (lib.mkIf (cfg.secretKeyPath != "unsafe") - { - E11SYNC_SECRET_KEY_PATH = "/run/credentials/secret_key"; - }) + { + TZ = "UTC"; + E11SYNC_DATABASE_PATH = cfg.databasePath; + } + (lib.mkIf (cfg.secretKeyPath != "unsafe") { + E11SYNC_SECRET_KEY_PATH = "/run/credentials/secret_key"; + }) ]; wantedBy = ["multi-user.target"]; serviceConfig = lib.mkMerge [ @@ -48,9 +53,10 @@ e11sync-backend: { Type = "notify"; NotifyAccess = "all"; Restart = "on-failure"; - RuntimeDirectory = "e11sync"; - StateDirectory = "e11sync"; - WorkingDirectory = "/var/lib/e11sync"; + RuntimeDirectory = "e11sync-backend"; + StateDirectory = "e11sync-backend"; + WorkingDirectory = "/var/lib/e11sync-backend"; + KillSignal = "SIGQUIT"; ExecStart = "${pkg-backend}/bin/e11sync-backend"; DynamicUser = true; diff --git a/pkgs/e11sync-backend.nix b/pkgs/e11sync-backend.nix index f1e8275..9c98b8a 100644 --- a/pkgs/e11sync-backend.nix +++ b/pkgs/e11sync-backend.nix @@ -32,6 +32,9 @@ in installPhase = '' cp -r . $out/app makeWrapper $out/app/manage.py $out/bin/e11sync \ + ${lib.optionalString (databasePath != null) '' + --set E11SYNC_DATABASE_PATH "${databasePath}" \ + ''} \ --set GEOIP_PATH "${geoip-mmdb}" makeWrapper ${uwsgi-python}/bin/uwsgi $out/bin/e11sync-backend \