nixos: use passAsFile to avoid "Argument list too long" error

This patch fixes "Argument list too long" build failure when passing a
list of store paths to system.extraDependencies that exceeds Linux'
MAX_ARG_STRLEN limit of 128 KiB. With the shortest possible derivation
names (one byte), the 128 KiB limit is equivalent to about 2850
derivations. With longer derivations names, the limit is hit earlier.
Fix this restriction.
This commit is contained in:
Bjørn Forsman 2023-05-11 22:43:12 +02:00
parent 57e7968e63
commit ef85c3fe51

View file

@ -78,7 +78,7 @@ let
${config.system.systemBuilderCommands}
echo -n "$extraDependencies" > $out/extra-dependencies
cp "$extraDependenciesPath" "$out/extra-dependencies"
${optionalString (!config.boot.isContainer && config.boot.bootspec.enable) ''
${config.boot.bootspec.writer}
@ -98,6 +98,7 @@ let
name = "nixos-system-${config.system.name}-${config.system.nixos.label}";
preferLocalBuild = true;
allowSubstitutes = false;
passAsFile = [ "extraDependencies" ];
buildCommand = systemBuilder;
inherit (pkgs) coreutils;