New User: Starting out direction(opinions)

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 that autoPatchelfs 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 use steam-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 because environment.systemPackages literally just puts stuff in PATH (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 your nixos channel. If you use another channel like home-manager, you’re better off updating with nix-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.
9 Likes