Merge pull request #32547 from obsidiansystems/fix-splice

top-level: Fix splicing, again

authored by John Ericson and committed by GitHub 3337e9ec 410ae8ab

+9 -10
+9 -10
pkgs/top-level/splice.nix
··· 37 inherit name; 38 value = let 39 defaultValue = mash.${name}; 40 - buildValue = buildPkgs.${name}; 41 - runValue = runPkgs.${name}; 42 augmentedValue = defaultValue 43 // (lib.optionalAttrs (buildPkgs ? ${name}) { nativeDrv = buildValue; }) 44 // (lib.optionalAttrs (runPkgs ? ${name}) { crossDrv = runValue; }); 45 - # Get the set of outputs of a derivation 46 tryGetOutputs = value0: let 47 - eval = builtins.tryEval value0; 48 - in getOutputs (if eval.success then eval.value else {}); 49 getOutputs = value: lib.genAttrs 50 (value.outputs or (lib.optional (value ? out) "out")) 51 (output: value.${output}); 52 in 53 - # Certain *Cross derivations will fail assertions, but we need their 54 - # nativeDrv. We are assuming anything that fails to evaluate is an 55 - # attrset (including derivation) and thus can be unioned. 56 - if !(builtins.tryEval defaultValue).success then augmentedValue 57 # The derivation along with its outputs, which we recur 58 # on to splice them together. 59 - else if lib.isDerivation defaultValue then augmentedValue 60 // splicer (tryGetOutputs buildValue) (getOutputs runValue) 61 # Just recur on plain attrsets 62 else if lib.isAttrs defaultValue then splicer buildValue runValue
··· 37 inherit name; 38 value = let 39 defaultValue = mash.${name}; 40 + # `or {}` is for the non-derivation attsert splicing case, where `{}` is the identity. 41 + buildValue = buildPkgs.${name} or {}; 42 + runValue = runPkgs.${name} or {}; 43 augmentedValue = defaultValue 44 // (lib.optionalAttrs (buildPkgs ? ${name}) { nativeDrv = buildValue; }) 45 // (lib.optionalAttrs (runPkgs ? ${name}) { crossDrv = runValue; }); 46 + # Get the set of outputs of a derivation. If one derivation fails to 47 + # evaluate we don't want to diverge the entire splice, so we fall back 48 + # on {} 49 tryGetOutputs = value0: let 50 + inherit (builtins.tryEval value0) success value; 51 + in getOutputs (lib.optionalAttrs success value); 52 getOutputs = value: lib.genAttrs 53 (value.outputs or (lib.optional (value ? out) "out")) 54 (output: value.${output}); 55 in 56 # The derivation along with its outputs, which we recur 57 # on to splice them together. 58 + if lib.isDerivation defaultValue then augmentedValue 59 // splicer (tryGetOutputs buildValue) (getOutputs runValue) 60 # Just recur on plain attrsets 61 else if lib.isAttrs defaultValue then splicer buildValue runValue