Skip to content

Commit

Permalink
nixos/paperless: mirror upstream admin user creation more closely
Browse files Browse the repository at this point in the history
Closes #249767
  • Loading branch information
SuperSandro2000 committed Dec 23, 2024
1 parent 88cfe2e commit 860c359
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions nixos/modules/services/misc/paperless.nix
Original file line number Diff line number Diff line change
Expand Up @@ -327,17 +327,20 @@ in
echo ${cfg.package.version} > "$versionFile"
fi
''
+ lib.optionalString (cfg.passwordFile != null) ''
export PAPERLESS_ADMIN_USER="''${PAPERLESS_ADMIN_USER:-admin}"
PAPERLESS_ADMIN_PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/PAPERLESS_ADMIN_PASSWORD")
export PAPERLESS_ADMIN_PASSWORD
superuserState="$PAPERLESS_ADMIN_USER:$PAPERLESS_ADMIN_PASSWORD"
superuserStateFile="${cfg.dataDir}/superuser-state"
if [[ $(cat "$superuserStateFile" 2>/dev/null) != "$superuserState" ]]; then
${cfg.package}/bin/paperless-ngx manage_superuser
echo "$superuserState" > "$superuserStateFile"
if [[ ${if cfg.passwordFile != null then "true" else "false"} || -n $PAPERLESS_ADMIN_PASSWORD ]]; then
export PAPERLESS_ADMIN_USER="''${PAPERLESS_ADMIN_USER:-admin}"
if [[ -e $CREDENTIALS_DIRECTORY/PAPERLESS_ADMIN_PASSWORD ]]; then
PAPERLESS_ADMIN_PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/PAPERLESS_ADMIN_PASSWORD")
export PAPERLESS_ADMIN_PASSWORD
fi
superuserState="$PAPERLESS_ADMIN_USER:$PAPERLESS_ADMIN_PASSWORD"
superuserStateFile="${cfg.dataDir}/superuser-state"
if [[ $(cat "$superuserStateFile" 2>/dev/null) != "$superuserState" ]]; then
${cfg.package}/bin/paperless-ngx manage_superuser
echo "$superuserState" > "$superuserStateFile"
fi
fi
'';
requires = lib.optional cfg.database.createLocally "postgresql.service";
Expand Down

0 comments on commit 860c359

Please sign in to comment.