modules/programs.nix: fix eval error when a program is suggestedBy multiple enabled packages

This commit is contained in:
Colin 2023-06-23 02:05:26 +00:00
parent 8cb236b0a9
commit ec3a7067b6
1 changed files with 11 additions and 5 deletions

View File

@ -52,11 +52,17 @@ let
};
enableFor.user = mkOption {
type = types.attrsOf types.bool;
default = joinAttrsets (mapAttrsToList (otherName: otherPkg:
optionalAttrs
(otherName != name && elem name otherPkg.suggestedPrograms && otherPkg.enableSuggested)
(filterAttrs (user: en: en) otherPkg.enableFor.user)
) cfg);
default =
let
suggestedBy = mapAttrsToList (otherName: otherPkg:
optionalAttrs
(otherName != name && elem name otherPkg.suggestedPrograms && otherPkg.enableSuggested)
(filterAttrs (user: en: en) otherPkg.enableFor.user)
) cfg;
in
# we can just // the attrs since each set is flat and the only value
# each attr can have here is `true`, never `false`
lib.foldl' (prev: next: prev // next) {} suggestedBy;
description = ''
place this program on the PATH for some specified user(s).
'';