I’m trying to take the next 3 baby steps but none worked.
Environment: ubuntu 16.4
Lets take the the one I want most 1st.
I’m trying to use tree in my build script.
I added it to my system using
nix-env -i tree
and it works.
which tree
/home/mral/.nix-profile/bin/tree
mral@sunburst20171202:/nix/store/4c4qq58y8yyj3dyhzv3737km0r7hbxpp-atrTest-0.0.1$ whereis tree
tree: /nix/store/p0cb4i0kwvkajxmvrzwfdsh5rzjrgig7-user-environment/bin/tree /usr/share/man/man3/tree.3.gz
I can run tree from a standard bash shell using unbutu’s bash shell and
from the nix-shell.
When I try to build my package is fails and I’m sure its because of the pure
build stuff that nix does, clearing path etc.
What I dont know is how to declare tree as a depencency.
I’ve tried all kinds of incantations following hints that I’ve seen in the manual.
Various combination of import, using { tree} or {} all in various places
and none have worked and none of the error messages gave me enough information
to know what I was doing wrong.
The nix expression is:
#atrTest.nix
let
pkgs = import <nixpkgs> {};
in
pkgs.stdenv.mkDerivation rec {
name = "atrTest-0.0.1";
#args = [" -v "];
builder = ./builder.sh;
src = ./makefile;
extraStuff = "extra stuff${name} for shell";
postInstall = ''
mkdir ''${out}/Assets
echo "all done now running postInstall for ${name}" > ''${out}/Assets/log.txt
'';
}
The build script is:
#builder.sh
source $stdenv/setup
echo "hi from $0, pwd=$(pwd), myName=${extraStuff}, arg=$1"
mkdir -p ${out}/atrnix
tree > ${out}/fileList.xml
echo "hi from nix-build" > ${out}/atrnix/hello.txt
echo "${postInstall}" >> ${out}/postSetup
I’m invoking it from a nix-shell as:
nix-build -K atrTest.nix
these derivations will be built:
/nix/store/9jnk7i5nr5i1ndzb3sja399xnfv4ykkp-atrTest-0.0.1.drv
building '/nix/store/9jnk7i5nr5i1ndzb3sja399xnfv4ykkp-atrTest-0.0.1.drv'...
hi from /nix/store/9k6jjnplqpg8mwjyy0wjailrng5g7gl9-builder.sh, pwd=/tmp/nix-build-atrTest-0.0.1.drv-5, myName=extra stuffatrTest-0.0.1 for shell, arg=
/nix/store/9k6jjnplqpg8mwjyy0wjailrng5g7gl9-builder.sh: line 6: tree: command not found
note: keeping build directory '/tmp/nix-build-atrTest-0.0.1.drv-5'
builder for '/nix/store/9jnk7i5nr5i1ndzb3sja399xnfv4ykkp-atrTest-0.0.1.drv' failed with exit code 127
error: build of '/nix/store/9jnk7i5nr5i1ndzb3sja399xnfv4ykkp-atrTest-0.0.1.drv' failed
I can see that it cann’t find the tree command but
how do I declare it as a dependency so it will be found?
I’ll start a seperate thread for the args problem, its been commented out for now.
I’ll start a seperate thread for the postInstall, its showing up as env variable
instead of being executed like I expected.