nix: deduplicate home-manager merging
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / Sandbox (push) Successful in 55s
Test / Sandbox (race detector) (push) Successful in 53s
Test / Fortify (race detector) (push) Successful in 50s
Test / Fpkg (push) Successful in 54s
Test / Fortify (push) Successful in 2m8s
Test / Flake checks (push) Successful in 1m7s
All checks were successful
Test / Create distribution (push) Successful in 44s
Test / Sandbox (push) Successful in 55s
Test / Sandbox (race detector) (push) Successful in 53s
Test / Fortify (race detector) (push) Successful in 50s
Test / Fpkg (push) Successful in 54s
Test / Fortify (push) Successful in 2m8s
Test / Flake checks (push) Successful in 1m7s
This becomes a problem when extraHomeConfig defines nixos module options. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
62
nixos.nix
62
nixos.nix
@@ -9,6 +9,7 @@ packages:
|
||||
let
|
||||
inherit (lib)
|
||||
lists
|
||||
attrsets
|
||||
mkMerge
|
||||
mkIf
|
||||
mapAttrs
|
||||
@@ -231,25 +232,48 @@ in
|
||||
{
|
||||
useUserPackages = false; # prevent users.users entries from being added
|
||||
|
||||
users = mkMerge (
|
||||
foldlAttrs (
|
||||
acc: _: fid:
|
||||
acc
|
||||
++ foldlAttrs (
|
||||
acc': _: app:
|
||||
acc'
|
||||
++ [
|
||||
{
|
||||
${getsubname fid app.identity} = mkMerge [
|
||||
cfg.extraHomeConfig
|
||||
app.extraConfig
|
||||
{ home.packages = app.packages; }
|
||||
];
|
||||
}
|
||||
]
|
||||
) [ { ${getsubname fid 0} = cfg.extraHomeConfig; } ] cfg.apps
|
||||
) [ privPackages ] cfg.users
|
||||
);
|
||||
users =
|
||||
mkMerge
|
||||
(foldlAttrs
|
||||
(
|
||||
acc: _: fid:
|
||||
foldlAttrs
|
||||
(
|
||||
acc: _: app:
|
||||
(
|
||||
let
|
||||
key = getsubname fid app.identity;
|
||||
in
|
||||
{
|
||||
usernames = acc.usernames // {
|
||||
${key} = true;
|
||||
};
|
||||
merge = acc.merge ++ [
|
||||
{
|
||||
${key} = mkMerge (
|
||||
[
|
||||
app.extraConfig
|
||||
{ home.packages = app.packages; }
|
||||
]
|
||||
++ lib.optional (!attrsets.hasAttrByPath [ key ] acc.usernames) cfg.extraHomeConfig
|
||||
);
|
||||
}
|
||||
];
|
||||
}
|
||||
)
|
||||
)
|
||||
{
|
||||
inherit (acc) usernames;
|
||||
merge = acc.merge ++ [ { ${getsubname fid 0} = cfg.extraHomeConfig; } ];
|
||||
}
|
||||
cfg.apps
|
||||
)
|
||||
{
|
||||
usernames = { };
|
||||
merge = [ privPackages ];
|
||||
}
|
||||
cfg.users
|
||||
).merge;
|
||||
};
|
||||
|
||||
users =
|
||||
|
||||
Reference in New Issue
Block a user