Also, a few newbie traps to be aware of:
- You’ll see stuff all over the place suggesting you use
nix-env -iA
… don’t. See Stop using nix-env and Depreciate the use of nix-env to install packages?. - If you try to run a binary compiled for normal linux distros on nixos, you’ll probably get a very confusing
No such file or directory
error from bash, despite the file clearly being right there. What doesn’t exist is the ELF interpreter (ld-linux.so
) specified in the binary (or possibly the interpreter specified in the hashbang). The solution is generally to write a derivation thatautoPatchelf
s the binary to use a version from the nix store, as well as find its libraries there, since there’s no global library search path on nixos. Another quick & temporary solution is to usesteam-run
. -
nix-channel
can be used as a normal user or as root, but it will manipulate a different set of channels in those 2 cases. Make sure you call it as the user you mean to (for a NixOS setup, that’s usually root). - When you go to install something, first check for a configuration module, and if that doesn’t exist, then install in
environment.systemPackages
. This is becauseenvironment.systemPackages
literally just puts stuff inPATH
(and a few other search paths), and can’t do any more complex configuration and integration stuff, which might be needed, depending on the software. -
nixos-rebuild switch --upgrade
ONLY updates yournixos
channel. If you use another channel likehome-manager
, you’re better off updating withnix-channel --update
. - Don’t install libraries globally. It doesn’t do anything. If you need them for development purposes, that’s where dev shells come in.