nix-pills
nix-pills copied to clipboard
Pill Nr.10 make command not found because source builder.sh exits nix-shell
In Pill Nr.10 it says:
You may get an error in the installation phase, because the user may not have the permission to write to /nix/store It didn't install, but it built. We're able to cd into hello-2.10 and type make, because now it's available.
Well for me this isn't true, because it says make: command not found
[jane@nixos:~/empty]$ nix-shell hello.nix
[nix-shell:~/empty]$ ls autotools.nix builder.sh hello-2.10 hello-2.10.tar.gz hello.nix
[nix-shell:~/empty]$ make make: command not found
[nix-shell:~/empty]$ source builder.sh /nix/store/svc70mmzrlgq42m9acs0prsmci7ksh6h-hello-2.10.tar.gz [......] /nix/store/9v78r3afqy9xn9zwdj9wfys6sk3vc01d-coreutils-8.31/bin/mkdir: cannot create directory '/nix/store/dwr4r7w7ayyzx3i7mb4gn1la57r2rsbc-hello2': Read-only file system make[3]: *** [Makefile:1554: install-binPROGRAMS] Error 1 make[3]: Leaving directory '/home/jane/empty/hello-2.10' make[2]: *** [Makefile:2377: install-am] Error 2 make[2]: Leaving directory '/home/jane/empty/hello-2.10' make[1]: *** [Makefile:1878: install-recursive] Error 1 make[1]: Leaving directory '/home/jane/empty/hello-2.10' make: *** [Makefile:2371: install] Error 2
[jane@nixos:~/empty]$ cd hello-2.10/
[jane@nixos:~/empty/hello-2.10]$ make make: command not found
This is because somehow the nix shell exited together with the "source builder.sh"- command
You can see this because before it said [nix-shell] now it says [jane@nixos] .
I don't know enough about nix-shell to decide whether this is an issue with the tutorial or an issue with nix-shell.
If i comment the following lines:
#make
#make install
#find $out -type f -exec patchelf --shrink-rpath '{}' \; -exec strip '{}' \; 2>/dev/null
in the builder.sh I can use make afterwards presumably because the command isn't failing and therefore it doesn't drop me out of the nix-shell.
The builder.sh
sets errexit
shell option on the first line, making the shell exit on an error.
source
shell builtin will run a script as if you manually ran the individual script lines in the active shell. So, unlike running it in a subprocess using bash ./buider.sh
, the shell spawned using nix-shell
will be the one running the commands and the one to exit.
I am not sure how it could have ever worked for anyone. Unless set -e
was added to the builder after chapter 10 was written without updating it (but that does not seem to be the case looking at the commit history).
In nixpkgs, we use approach more similar to section 10.2. “A builder for nix-shell”, where we only source the setup part but not configure/make/install.
Ok so it's an issue with the tutorial, thx for clarifying and for the explanation. Hopefully this can be fixed, so no one else stumbles across this.
Solve this.
Has same issue, but with removing 2>/dev/null
from find
command gives me point, that the find command not found itself. So, i patch the baseInputs
and add findutils
to them.