Loading pkgs/stdenv/generic/make-derivation.nix +7 −1 Original line number Diff line number Diff line Loading @@ -574,6 +574,12 @@ let "The ‘env’ attribute set can only contain derivation, string, boolean or integer attributes. The ‘${n}’ attribute is of type ${builtins.typeOf v}."; v) env; # Fixed-output derivations may not reference other paths, which means that # for a fixed-output derivation, the corresponding inputDerivation should # *not* be fixed-output. To achieve this we simply delete the attributes that # would make it fixed-output. deleteFixedOutputRelatedAttrs = lib.flip builtins.removeAttrs [ "outputHashAlgo" "outputHash" "outputHashMode" ]; in extendDerivation Loading @@ -584,7 +590,7 @@ extendDerivation # This allows easy building and distributing of all derivations # needed to enter a nix-shell with # nix-build shell.nix -A inputDerivation inputDerivation = derivation (derivationArg // { inputDerivation = derivation (deleteFixedOutputRelatedAttrs derivationArg // { # Add a name in case the original drv didn't have one name = derivationArg.name or "inputDerivation"; # This always only has one output Loading pkgs/test/stdenv/default.nix +22 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,28 @@ in touch $out ''; test-inputDerivation-fixed-output = let inherit (stdenv.mkDerivation { dep1 = derivation { name = "dep1"; builder = "/bin/sh"; args = [ "-c" ": > $out" ]; system = builtins.currentSystem; }; dep2 = derivation { name = "dep2"; builder = "/bin/sh"; args = [ "-c" ": > $out" ]; system = builtins.currentSystem; }; name = "meow"; outputHash = "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="; outputHashMode = "flat"; outputHashAlgo = "sha256"; buildCommand = '' touch $out ''; passAsFile = [ "dep2" ]; }) inputDerivation; in runCommand "test-inputDerivation" { exportReferencesGraph = [ "graph" inputDerivation ]; } '' grep ${inputDerivation.dep1} graph grep ${inputDerivation.dep2} graph touch $out ''; test-prepend-append-to-var = testPrependAndAppendToVar { name = "test-prepend-append-to-var"; stdenv' = bootStdenv; Loading Loading
pkgs/stdenv/generic/make-derivation.nix +7 −1 Original line number Diff line number Diff line Loading @@ -574,6 +574,12 @@ let "The ‘env’ attribute set can only contain derivation, string, boolean or integer attributes. The ‘${n}’ attribute is of type ${builtins.typeOf v}."; v) env; # Fixed-output derivations may not reference other paths, which means that # for a fixed-output derivation, the corresponding inputDerivation should # *not* be fixed-output. To achieve this we simply delete the attributes that # would make it fixed-output. deleteFixedOutputRelatedAttrs = lib.flip builtins.removeAttrs [ "outputHashAlgo" "outputHash" "outputHashMode" ]; in extendDerivation Loading @@ -584,7 +590,7 @@ extendDerivation # This allows easy building and distributing of all derivations # needed to enter a nix-shell with # nix-build shell.nix -A inputDerivation inputDerivation = derivation (derivationArg // { inputDerivation = derivation (deleteFixedOutputRelatedAttrs derivationArg // { # Add a name in case the original drv didn't have one name = derivationArg.name or "inputDerivation"; # This always only has one output Loading
pkgs/test/stdenv/default.nix +22 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,28 @@ in touch $out ''; test-inputDerivation-fixed-output = let inherit (stdenv.mkDerivation { dep1 = derivation { name = "dep1"; builder = "/bin/sh"; args = [ "-c" ": > $out" ]; system = builtins.currentSystem; }; dep2 = derivation { name = "dep2"; builder = "/bin/sh"; args = [ "-c" ": > $out" ]; system = builtins.currentSystem; }; name = "meow"; outputHash = "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="; outputHashMode = "flat"; outputHashAlgo = "sha256"; buildCommand = '' touch $out ''; passAsFile = [ "dep2" ]; }) inputDerivation; in runCommand "test-inputDerivation" { exportReferencesGraph = [ "graph" inputDerivation ]; } '' grep ${inputDerivation.dep1} graph grep ${inputDerivation.dep2} graph touch $out ''; test-prepend-append-to-var = testPrependAndAppendToVar { name = "test-prepend-append-to-var"; stdenv' = bootStdenv; Loading