After that I compiled and installed nix with make, and everything went fine.
Them, I added the stable channel using nix-channel --add $THE_URL and then I tried to install something.
nix-env -i gcc
It get stuck with an error like: /build/$somethign is not a directory.
The solution to the problem was to create the directory /build the next problem was indeed not enough permission on /build (correct, I created the directory as root, while I am building as user ubuntu). I change the ownership of the directory to ubuntu and now it is happily compiling.
I believe the problem is that the environment variable NIX_BUILD_TOP is empty during the build process. I tried to lookup into the code, but that variable seems to be set in a quite straightforward way.
How can I fix the problem? I would like nix to build somewhere else than the directory /build I create for it.
NIX_BUILD_TOP is set by Nix before it forks off the builder. Nix derives this directory sandbox-build-dir in nix.conf, which defaults to /build. Dunno if the default can be set at build time, but you can set it in /etc/nix/nix.conf or ~/.config/nix/nix.conf.
Note that by using a custom store dir, you will not be able to get binaries from the binary cache, and will build everything from source. You can get around this by setting store = /path/to/store in nix.conf instead of doing what you’re doing, which instead uses chroot to emulate /nix/store in a user owned directory. But this requires user namespaces to do it without root, which I’m guessing your distro doesn’t enable (otherwise I think it’d be able to set up /build via the chroot it would make for the build sandbox, even without store).
I am already doing something a little too fancy, so chroot is out of the question for now. I am fine with building everything from scratch
I believe that the installation from source of nix does not install any of the shell scripts and configurations file needed to actually use the package manager.
Should I report it somewhere? How do I install all the necessary configuration scripts?
Hummmm, I changed the prefix, but yes, eventually I found the nix.sh file.
However, trying to source that file gives problems like:
$ source /cvmfs/packages.redbeardlab.com/nix/installation/etc/profile.d/nix.sh
bash: stat: command not found
bash: id: command not found
bash: stat: command not found
bash: id: command not found