Skip to content

Commit 7f3bf67

Browse files
committed
use Hamish's suggestion for faster dedup
1 parent 872043a commit 7f3bf67

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

builder/shell-for.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,14 @@ 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-
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');
98+
#
99+
# Version of `lib.unique` that should be fast if the name attributes are unique
100+
uniqueWithName = list:
101+
lib.concatMap lib.unique (
102+
builtins.attrValues (
103+
builtins.groupBy (x: if __typeOf x == "set" then x.name or "noname" else "notset") list));
104+
allSystemInputs = lib.concatMap (c: c.buildInputs ++ c.propagatedBuildInputs) selectedComponents;
105+
systemInputs = removeSelectedInputs (uniqueWithName allSystemInputs);
103106

104107
nativeBuildInputs = removeSelectedInputs
105108
(lib.concatMap (c: c.executableToolDepends) selectedComponents);

0 commit comments

Comments
 (0)