Skip to content

Commit 872043a

Browse files
committed
use attrsets for deduplication
'name' should be unique for haskell packages; not necessarily so for other things
1 parent 839515b commit 872043a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

builder/shell-for.nix

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,11 @@ let
9595
#
9696
# Also, we take care to keep duplicates out of the list, otherwise we may see
9797
# "Argument list too long" errors from bash when entering a shell.
98-
addUnique = new: existing:
99-
lib.lists.foldr (x: acc: if lib.lists.any (y: x == y) acc then acc else [x] ++ acc) existing new;
100-
concatSystemInputs = inputsSoFar: c:
101-
addUnique c.buildInputs (addUnique c.propagatedBuildInputs inputsSoFar);
102-
systemInputs' = lib.lists.foldl concatSystemInputs [] selectedComponents;
103-
systemInputs = removeSelectedInputs systemInputs';
98+
uniqueInputs = inputList: builtins.listToAttrs (builtins.map (x: lib.nameValuePair (x.name) x) inputList);
99+
unionComponentInputs = inputsSoFar: c:
100+
inputsSoFar // uniqueInputs c.buildInputs // uniqueInputs c.propagatedBuildInputs;
101+
systemInputs' = lib.lists.foldl unionComponentInputs {} selectedComponents;
102+
systemInputs = removeSelectedInputs (builtins.attrValues systemInputs');
104103

105104
nativeBuildInputs = removeSelectedInputs
106105
(lib.concatMap (c: c.executableToolDepends) selectedComponents);

0 commit comments

Comments
 (0)