Commit 771a0ec7 authored by Felix Buehler's avatar Felix Buehler
Browse files

nixos/photoprism: add databasePasswordFile option

parent 53f95e2e
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -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
      '';
    };