I’m just adding my 2 cents to the knowledge base for other noobs like myself.
I’ve only been at this for a few days so this may seem obvious to most of you but its news to me.
The problem I gave myself was to add something to my /nix/store, a simple mark of
some kind.
I started with the example 14.1 and 14.2. I didnt want to remake hello,
I was able to add that from the public repository using
nix-env -i hello
I want to add something that I created. I was having no luck, most of the time I got
error: cannot auto-call a function that has an argument without a default value ('stdenv')
I still dont know what this error message is tring to tell me or what to do about
it but I found incident 2259 over on github and @vaibhavsagar gave me an incantation that worked.
I have a simple two file solution: please correct me if I my usage of these terms is wrong.
The nix expression file named ./atrTest.nix saved in my current directory.
let
pkgs = import <nixpkgs> {};
in
pkgs.stdenv.mkDerivation {
name = "atrTest-0.0.1";
builder = ./builder.sh;
src = ./test.txt;
}
is the instruction to nix-build and a simple bash script named ./builder.sh
which is called by nix-build to actually do the heavy lifting.
source $stdenv/setup
mkdir -p ${out}/atrnix
echo "hi from nix-build" > ${out}/atrnix/hello.txt
I ran
nix-build ./atrTest.nix
and got
these derivations will be built:
/nix/store/k41xk89fqw4sa3ysiz3j1afgq91wjhhs-atrTest-0.0.1.drv
building '/nix/store/k41xk89fqw4sa3ysiz3j1afgq91wjhhs-atrTest-0.0.1.drv'...
/nix/store/aw157j4zdgnjbc0yhi40mf0ir3mqxg29-atrTest-0.0.1
I cd to the /nix/store/aw157… directory and to see my subdirectory with
the hello.txt file in it.
It doesnt do anything but I’ve made a mark.
Success:-)
Thanks to the development team and the FLOSS eco system that they support,
my sense is that nix is going to be very useful.