That is, runCommandWith
is defined thus:
(top part of `runCommandWith`)
runCommandWith =
let
defaultStdenv = stdenv;
in
{ stdenv ? defaultStdenv
, runLocal ? false
, derivationArgs ? {}
, name
}: buildCommand:
stdenv.mkDerivation ({
enableParallelBuilding = true;
inherit buildCommand name;
passAsFile = [ "buildCommand" ]
++ (derivationArgs.passAsFile or []);
}
// (lib.optionalAttrs runLocal {
preferLocalBuild = true;
allowSubstitutes = false;
})
// builtins.removeAttrs derivationArgs [ "passAsFile" ]);
I think I get why the builtins.removeAttrs
was needed: if derivationArgs
would have simply been updated / merged in the end, that the previous passAsFile
attribute would have been overwritten (if derivationArgs
had a passAsFile
attribute, that is).
nix-repl> inputAttributeSet = { a = [ 3 ]; r = "x"; s = "x"; }
nix-repl> :p ({ a = [ 1 2 ] ++ inputAttributeSet.a; b = 3; }
// inputAttributeSet)
{ a = [ 3 ]; b = 3; r = "x"; s = "x"; }
nix-repl> :p ({ a = [ 1 2 ] ++ inputAttributeSet.a; b = 3; }
// builtins.removeAttrs inputAttributeSet [ "a" ])
{ a = [ 1 2 3 ]; b = 3; r = "x"; s = "x"; }
1. Is there a reason why passAsFile
isn’t simply defined in the end, once?
(top part of `runCommandWith`)
runCommandWith =
let
defaultStdenv = stdenv;
in
{ stdenv ? defaultStdenv
, runLocal ? false
, derivationArgs ? {}
, name
}: buildCommand:
stdenv.mkDerivation ({
enableParallelBuilding = true;
inherit buildCommand name;
}
// (lib.optionalAttrs runLocal {
preferLocalBuild = true;
allowSubstitutes = false;
})
// derivationArgs
// { passAsFile = [ "buildCommand" ] ++ (derivationArgs.passAsFile or []); }
);
That is:
nix-repl> :p ({ b = 3; }
// inputAttributeSet
// { a = [ 1 2 ] ++ inputAttributeSet.a; })
{ a = [ 1 2 3 ]; b = 3; r = "x"; s = "x"; }
This version looks more readable to me, but then again, I have a tendency to miss obvious things, and this part of Nixpkgs has a lot of complex stuff.