diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index cb005a1e9b96..93612cee03f1 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -390,6 +390,8 @@ - `bind.cacheNetworks` now only controls access for recursive queries, where it previously controlled access for all queries. +- [`services.mongodb.enableAuth`](#opt-services.mongodb.enableAuth) now uses the newer [mongosh](https://github.com/mongodb-js/mongosh) shell instead of the legacy shell to configure the initial superuser. You can configure the mongosh package to use through the [`services.mongodb.mongoshPackage`](#opt-services.mongodb.mongoshPackage) option. + - The paperless module now has an option for regular automatic export of documents data using the integrated document exporter. diff --git a/nixos/modules/services/databases/mongodb.nix b/nixos/modules/services/databases/mongodb.nix index 90b749574bf5..206b076dab49 100644 --- a/nixos/modules/services/databases/mongodb.nix +++ b/nixos/modules/services/databases/mongodb.nix @@ -10,6 +10,8 @@ let mongodb = cfg.package; + mongoshExe = lib.getExe cfg.mongoshPackage; + mongoCnf = cfg: pkgs.writeText "mongodb.conf" '' @@ -36,6 +38,8 @@ in package = lib.mkPackageOption pkgs "mongodb" { }; + mongoshPackage = lib.mkPackageOption pkgs "mongosh" { }; + user = lib.mkOption { type = lib.types.str; default = "mongodb"; @@ -125,8 +129,6 @@ in }; users.groups.mongodb = lib.mkIf (cfg.user == "mongodb") { }; - environment.systemPackages = [ mongodb ]; - systemd.services.mongodb = { description = "MongoDB server"; @@ -164,10 +166,10 @@ in if ! test -e "${cfg.dbpath}/.auth_setup_complete"; then systemd-run --unit=mongodb-for-setup --uid=${cfg.user} ${mongodb}/bin/mongod --config ${mongoCnf cfg_} # wait for mongodb - while ! ${mongodb}/bin/mongo --eval "db.version()" > /dev/null 2>&1; do sleep 0.1; done + while ! ${mongoshExe} --eval "db.version()" > /dev/null 2>&1; do sleep 0.1; done - ${mongodb}/bin/mongo <