nixos/photoprism: add databasePasswordFile option

This commit is contained in:
Felix Buehler
2025-10-01 23:13:34 +02:00
parent 53f95e2ea8
commit 771a0ec704
+20 -3
View File
@@ -40,6 +40,14 @@ in
'';
};
databasePasswordFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Database password file.
'';
};
address = lib.mkOption {
type = lib.types.str;
default = "localhost";
@@ -114,9 +122,12 @@ in
cfg.storagePath
];
LoadCredential = lib.optionalString (
cfg.passwordFile != null
) "PHOTOPRISM_ADMIN_PASSWORD_FILE:${cfg.passwordFile}";
LoadCredential = [
(lib.optionalString (cfg.passwordFile != null) "PHOTOPRISM_ADMIN_PASSWORD_FILE=${cfg.passwordFile}")
(lib.optionalString (
cfg.databasePasswordFile != null
) "PHOTOPRISM_DATABASE_PASSWORD=${cfg.databasePasswordFile}")
];
LockPersonality = true;
PrivateDevices = true;
@@ -151,6 +162,9 @@ in
${lib.optionalString (cfg.passwordFile != null) ''
export PHOTOPRISM_ADMIN_PASSWORD_FILE=$CREDENTIALS_DIRECTORY/PHOTOPRISM_ADMIN_PASSWORD_FILE
''}
${lib.optionalString (cfg.databasePasswordFile != null) ''
export PHOTOPRISM_DATABASE_PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/PHOTOPRISM_DATABASE_PASSWORD")
''}
exec ${cfg.package}/bin/photoprism migrations run -f
'';
@@ -158,6 +172,9 @@ in
${lib.optionalString (cfg.passwordFile != null) ''
export PHOTOPRISM_ADMIN_PASSWORD_FILE=$CREDENTIALS_DIRECTORY/PHOTOPRISM_ADMIN_PASSWORD_FILE
''}
${lib.optionalString (cfg.databasePasswordFile != null) ''
export PHOTOPRISM_DATABASE_PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/PHOTOPRISM_DATABASE_PASSWORD")
''}
exec ${cfg.package}/bin/photoprism start
'';
};