diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index e3edc9dda6b6..73134414138b 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -106,6 +106,7 @@ firebird = 95; redis = 96; haproxy = 97; + mongodb = 98; # When adding a uid, make sure it doesn't match an existing gid. diff --git a/nixos/modules/services/databases/mongodb.nix b/nixos/modules/services/databases/mongodb.nix index d62994158939..213a60687b23 100644 --- a/nixos/modules/services/databases/mongodb.nix +++ b/nixos/modules/services/databases/mongodb.nix @@ -90,8 +90,9 @@ in config = mkIf config.services.mongodb.enable { - users.extraUsers = singleton - { name = cfg.user; + users.extraUsers.mongodb = mkIf (cfg.user == "mongodb") + { name = "mongodb"; + uid = config.ids.uids.mongodb; description = "MongoDB server user"; };