what is it?

a purely functional package manager. This means that it treats packages like values in purely functional programming languages such as Haskell

installation

official method

multi-user installation on Linux

sh <(curl -L https://nixos.org/nix/install) --daemon

determinate systems installer

an alternative to the official method with some benefits

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

cleaning up space

nix-store --verify --check-contents --repair
nix-collect-garbage
# leaves only a single generation, prevents rollback
nix-collect-garbage --delete-old

nix-store --optimize replaces copies with hardlinks, cutting down on disk space

review nix-store --gc --print-roots and decide if there are roots that can be removed

running a program

running vim from the nixpkgs flake (without installing it)

nix run nixpkgs#vim

shell

run a shell in which the specified packages are available

# shell providing GNU Hello from NixOS 20.03
nix shell nixpkgs/nixos-20.03#hello
# install multiple packages
nix shell nixpkgs#uv nixpkgs#libpqxx

configuration

/etc/nix/nix.conf
# use as many jobs as number of CPUs for builder
max-jobs = auto