diff --git a/nixos/modules/services/databases/mongodb.nix b/nixos/modules/services/databases/mongodb.nix index 129b679d73f8..1eba6fdc60af 100644 --- a/nixos/modules/services/databases/mongodb.nix +++ b/nixos/modules/services/databases/mongodb.nix @@ -199,7 +199,7 @@ in postStart = '' if test -e "${cfg.dbpath}/.first_startup"; then ${lib.optionalString (cfg.initialScript != null) '' - initialRootPassword=$(<${cfg.initialRootPasswordFile}) + ${lib.optionalString (cfg.enableAuth) "initialRootPassword=$(<${cfg.initialRootPasswordFile})"} ${mongoshExe} ${lib.optionalString (cfg.enableAuth) "-u root -p $initialRootPassword"} admin "${cfg.initialScript}" ''} rm -f "${cfg.dbpath}/.first_startup"