A baby step by making my own hello file

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.

  pkgs = import <nixpkgs> {};
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:
building '/nix/store/k41xk89fqw4sa3ysiz3j1afgq91wjhhs-atrTest-0.0.1.drv'...

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.

Thanks to the development team and the FLOSS eco system that they support,
my sense is that nix is going to be very useful.

1 Like

Congratulations and welcome :wink: