Unverified Commit 1e01c30c authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

nixos/paperless: mirror upstream admin user creation more closely (#367545)

parents 5a84e447 7afa349e
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -421,8 +421,7 @@ in
          };
          environment = env;

          preStart =
            ''
          preStart = ''
              # remove old papaerless-manage symlink
              # TODO: drop with NixOS 25.11
              [[ -L '${cfg.dataDir}/paperless-manage' ]] && rm '${cfg.dataDir}/paperless-manage'
@@ -450,11 +449,13 @@ in

              echo ${cfg.package.version} > "$versionFile"
            fi
            ''
            + lib.optionalString (cfg.passwordFile != null) ''

            if ${lib.boolToString (cfg.passwordFile != null)} || [[ -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"

@@ -462,6 +463,7 @@ in
                ${cfg.package}/bin/paperless-ngx manage_superuser
                echo "$superuserState" > "$superuserStateFile"
              fi
            fi
          '';
          requires = lib.optional cfg.database.createLocally "postgresql.service";
          after =