summary refs log tree commit diff
path: root/pkgs/stdenv/generic
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-05-08 11:55:36 +0000
committerAlyssa Ross <hi@alyssa.is>2023-05-09 14:00:57 +0000
commita295c4566e43e71d3944ee435629cf7ec5e181f7 (patch)
treecbecc5e1d629194440b151060b070764d68e3501 /pkgs/stdenv/generic
parent884ffbd847e015e0d6cb2767ba72f7e7320bf8ef (diff)
downloadnixpkgs-a295c4566e43e71d3944ee435629cf7ec5e181f7.tar
nixpkgs-a295c4566e43e71d3944ee435629cf7ec5e181f7.tar.gz
nixpkgs-a295c4566e43e71d3944ee435629cf7ec5e181f7.tar.bz2
nixpkgs-a295c4566e43e71d3944ee435629cf7ec5e181f7.tar.lz
nixpkgs-a295c4566e43e71d3944ee435629cf7ec5e181f7.tar.xz
nixpkgs-a295c4566e43e71d3944ee435629cf7ec5e181f7.tar.zst
nixpkgs-a295c4566e43e71d3944ee435629cf7ec5e181f7.zip
stdenv: fix inputDerivation with passAsFile
passAsFile passes the values of Nix bindings to the builder as
files, so if those values contained references, they wouldn't end up
in the inputDerivation output.  To fix that, append the contents of
every such passed file to the output.

We only have shell builtins in this derivation, so we can't use cat.
The only way I know of appending the contents of one file to another
using only shell builtins is as I've done here, but it requires
putting the contents of the file on echo's argv.  This might end up
causing problems with large files.  Regardless, I think we should try
this, as a failure is better than silently producing an incorrect
result like the previous behavior.
Diffstat (limited to 'pkgs/stdenv/generic')
-rw-r--r--pkgs/stdenv/generic/make-derivation.nix8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix
index 0515494ec98..70e5d4a7e94 100644
--- a/pkgs/stdenv/generic/make-derivation.nix
+++ b/pkgs/stdenv/generic/make-derivation.nix
@@ -545,7 +545,13 @@ lib.extendDerivation
        # binaries). By writing this to $out, Nix can find and register
        # them as runtime dependencies (since Nix greps for store paths
        # through $out to find them)
-       args = [ "-c" "export > $out" ];
+       args = [ "-c" ''
+         export > $out
+         for var in $passAsFile; do
+             pathVar="''${var}Path"
+             printf "%s" "$(< "''${!pathVar}")" >> $out
+         done
+       '' ];
 
        # inputDerivation produces the inputs; not the outputs, so any
        # restrictions on what used to be the outputs don't serve a purpose