top-level: Fix splicing in the presence of evaluation errors

- No more `or {}`, this was misleading at best since those values
   wouldn't be used unless the attr they are defined from was present
   anyways.

 - `tryEval` for get outputs. This ensures that if some derivations fail, they
   won't take out the others. This benefited from the `or {}` before, but that
   was never good enough. `tryEval` is strictly better.
This commit is contained in:
John Ericson 2017-12-09 14:27:24 -05:00
parent 43d5c5d6db
commit 965cc5da57

View file

@ -37,12 +37,15 @@ let
inherit name;
value = let
defaultValue = mash.${name};
buildValue = buildPkgs.${name} or {};
runValue = runPkgs.${name} or {};
buildValue = buildPkgs.${name};
runValue = runPkgs.${name};
augmentedValue = defaultValue
// (lib.optionalAttrs (buildPkgs ? ${name}) { nativeDrv = buildValue; })
// (lib.optionalAttrs (runPkgs ? ${name}) { crossDrv = runValue; });
# Get the set of outputs of a derivation
tryGetOutputs = value0: let
eval = builtins.tryEval value0;
in getOutputs (if eval.success then eval.value else {});
getOutputs = value: lib.genAttrs
(value.outputs or (lib.optional (value ? out) "out"))
(output: value.${output});
@ -54,7 +57,7 @@ let
# The derivation along with its outputs, which we recur
# on to splice them together.
else if lib.isDerivation defaultValue then augmentedValue
// splicer (getOutputs buildValue) (getOutputs runValue)
// splicer (tryGetOutputs buildValue) (getOutputs runValue)
# Just recur on plain attrsets
else if lib.isAttrs defaultValue then splicer buildValue runValue
# Don't be fancy about non-derivations. But we could have used used