diff options
author | Jade Lovelace <software@lfcode.ca> | 2024-04-15 00:50:38 -0700 |
---|---|---|
committer | Jade Lovelace <software@lfcode.ca> | 2024-04-15 00:52:28 -0700 |
commit | 78945a827cc5f2e5b97b7ca9807f7ac111086a1e (patch) | |
tree | b54a017685dbef5ab3531b9548a5c9457601629d /pkgs/test/stdenv | |
parent | a4a608e7940dc3034bc85d1e5e2a59c86bbd58a3 (diff) |
stdenv: make inputDerivation never fixed-output
This fixes using inputDerivation on derivations that are fixed-output. Previously: ``` nix-repl> drv = runCommand "huh" { outputHash = "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="; outputHashAlgo = "sha256"; outputHashType = "flat"; } "touch $out" nix-repl> drv.inputDerivation «derivation /nix/store/d8mjs6cmmvsr1fv7psm6imis5pmh9bcs-huh.drv» nix-repl> :b drv.inputDerivation error: fixed output derivation 'huh' is not allowed to refer to other store paths. You may need to use the 'unsafeDiscardReferences' derivation attribute, see the manual for more details. ``` Fixes: https://github.com/NixOS/nixpkgs/issues/304209
Diffstat (limited to 'pkgs/test/stdenv')
-rw-r--r-- | pkgs/test/stdenv/default.nix | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pkgs/test/stdenv/default.nix b/pkgs/test/stdenv/default.nix index 3882eb2b625c5..e06759fa28bd4 100644 --- a/pkgs/test/stdenv/default.nix +++ b/pkgs/test/stdenv/default.nix @@ -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; |