1

fix databasePath

This commit is contained in:
Motiejus Jakštys 2024-01-16 22:59:18 +02:00
parent 669939f2c1
commit 6038aad312
2 changed files with 19 additions and 10 deletions

View File

@ -18,13 +18,16 @@ e11sync-backend: {
type = port; type = port;
default = 8002; default = 8002;
}; };
databasePath = lib.mkOption {
type = path;
default = "/var/lib/e11sync-backend/db.sqlite3";
};
}; };
config = let config = let
cfg = config.e11sync; cfg = config.e11sync;
pkg-backend = e11sync-backend.override { pkg-backend = e11sync-backend.override {
inherit (cfg) backendPort; inherit (cfg) backendPort databasePath;
databasePath = "/var/lib/e11sync/db.sqlite3";
}; };
in in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {
@ -36,11 +39,13 @@ e11sync-backend: {
e11sync-backend = { e11sync-backend = {
description = "e11sync backend"; description = "e11sync backend";
environment = lib.mkMerge [ environment = lib.mkMerge [
{TZ = "UTC";} {
(lib.mkIf (cfg.secretKeyPath != "unsafe") TZ = "UTC";
{ E11SYNC_DATABASE_PATH = cfg.databasePath;
E11SYNC_SECRET_KEY_PATH = "/run/credentials/secret_key"; }
}) (lib.mkIf (cfg.secretKeyPath != "unsafe") {
E11SYNC_SECRET_KEY_PATH = "/run/credentials/secret_key";
})
]; ];
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
serviceConfig = lib.mkMerge [ serviceConfig = lib.mkMerge [
@ -48,9 +53,10 @@ e11sync-backend: {
Type = "notify"; Type = "notify";
NotifyAccess = "all"; NotifyAccess = "all";
Restart = "on-failure"; Restart = "on-failure";
RuntimeDirectory = "e11sync"; RuntimeDirectory = "e11sync-backend";
StateDirectory = "e11sync"; StateDirectory = "e11sync-backend";
WorkingDirectory = "/var/lib/e11sync"; WorkingDirectory = "/var/lib/e11sync-backend";
KillSignal = "SIGQUIT";
ExecStart = "${pkg-backend}/bin/e11sync-backend"; ExecStart = "${pkg-backend}/bin/e11sync-backend";
DynamicUser = true; DynamicUser = true;

View File

@ -32,6 +32,9 @@ in
installPhase = '' installPhase = ''
cp -r . $out/app cp -r . $out/app
makeWrapper $out/app/manage.py $out/bin/e11sync \ makeWrapper $out/app/manage.py $out/bin/e11sync \
${lib.optionalString (databasePath != null) ''
--set E11SYNC_DATABASE_PATH "${databasePath}" \
''} \
--set GEOIP_PATH "${geoip-mmdb}" --set GEOIP_PATH "${geoip-mmdb}"
makeWrapper ${uwsgi-python}/bin/uwsgi $out/bin/e11sync-backend \ makeWrapper ${uwsgi-python}/bin/uwsgi $out/bin/e11sync-backend \