Skip to content

Commit 839515b

Browse files
committed
deduplicate build inputs for the shell
#1297
1 parent 2aca501 commit 839515b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

builder/shell-for.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,16 @@ let
9292
# We need to remove any inputs which are selected components (see above).
9393
# `buildInputs`, `propagatedBuildInputs`, and `executableToolDepends` contain component
9494
# derivations, not packages, so we use `removeSelectedInputs`).
95-
systemInputs = removeSelectedInputs (lib.concatMap
96-
(c: c.buildInputs ++ c.propagatedBuildInputs) selectedComponents);
95+
#
96+
# Also, we take care to keep duplicates out of the list, otherwise we may see
97+
# "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';
104+
97105
nativeBuildInputs = removeSelectedInputs
98106
(lib.concatMap (c: c.executableToolDepends) selectedComponents);
99107

0 commit comments

Comments
 (0)