Let’s say some package foo
depends on a package abc
such that when foo
is built, it expects abc
to be under /usr/local/bin
or at a location referred by an environment variable, ABC_BIN_DIR
. How can one access the location of abc
(under /nix/store/...
) in order to set the ABC_BIN_DIR
env var in the builder script.
The following derivation snippet can be used as an example:
with import <nixpkgs> {};
stdenv.mkDerivation {
name = "foo";
src = fetchFromGitHub {
owner = "xyz";
repo = "foo";
rev = "zzz...";
sha256 = "aaa...";
fetchSubmodules = true;
};
buildInputs = [ (import ./abc.nix { }) ];
builder = ./builder.sh;
}
Can abc
's location be access via the outPath
attribute (as suggested in NixOS - Nix Pills)?
Does one need to set an attribute such as in:
let
abc = import ./abc.nix { };
in
stdenv.mkDerivation {
# ...
inherit abc;
}
and then in builder.sh
:
source $stdenv/setup
export ABC_BIN_DIR=$abc.outPath