1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-09 16:13:54 +02:00

Add a mechanism for derivation attributes to reference the derivation's outputs

For example, you can now say:

  configureFlags = "--prefix=${placeholder "out"} --includedir=${placeholder "dev"}";

The strings returned by the ‘placeholder’ builtin are replaced at
build time by the actual store paths corresponding to the specified
outputs.

Previously, you had to work around the inability to self-reference by doing stuff like:

  preConfigure = ''
    configureFlags+=" --prefix $out --includedir=$dev"
  '';

or rely on ad-hoc variable interpolation semantics in Autoconf or Make
(e.g. --prefix=\$(out)), which doesn't always work.
This commit is contained in:
Eelco Dolstra 2016-08-17 15:12:54 +02:00
parent ac841a4679
commit 22d6e31fc6
7 changed files with 63 additions and 16 deletions

22
tests/placeholders.sh Normal file
View file

@ -0,0 +1,22 @@
source common.sh
clearStore
nix-build --no-out-link -E '
with import ./config.nix;
mkDerivation {
name = "placeholders";
outputs = [ "out" "bin" "dev" ];
buildCommand = "
echo foo1 > $out
echo foo2 > $bin
echo foo3 > $dev
[[ $(cat ${placeholder "out"}) = foo1 ]]
[[ $(cat ${placeholder "bin"}) = foo2 ]]
[[ $(cat ${placeholder "dev"}) = foo3 ]]
";
}
'
echo XYZZY