1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

nixos: only refer to users.users if needed

Fixes a regression of GitHub issue #594. Before this commit,
attempting to dynamically configure Home Manager with contents of
nixos's users.users when using the nixos module would result in
infinite recursion.

PR #4368
This commit is contained in:
TNE 2023-08-21 19:55:03 +00:00 committed by Robert Helgesson
parent a0ad98174c
commit ca4126e3c5
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -94,7 +94,15 @@ in {
};
};
config = mkIf (cfg.users != { }) {
config = (mkMerge [
# Fix potential recursion when configuring home-manager users based on values in users.users #594
(mkIf (cfg.useUserPackages && cfg.users != { }) {
users.users =
(mapAttrs (username: usercfg: { packages = [ usercfg.home.path ]; })
cfg.users);
environment.pathsToLink = [ "/etc/profile.d" ];
})
(mkIf (cfg.users != { }) {
warnings = flatten (flip mapAttrsToList cfg.users (user: config:
flip map config.warnings (warning: "${user} profile: ${warning}")));
@ -103,11 +111,6 @@ in {
inherit (assertion) assertion;
message = "${user} profile: ${assertion.message}";
})));
users.users = mkIf cfg.useUserPackages
(mapAttrs (username: usercfg: { packages = [ usercfg.home.path ]; })
cfg.users);
environment.pathsToLink = mkIf cfg.useUserPackages [ "/etc/profile.d" ];
};
})
]);
}