Setup
The official install script is available at NixOS, but the installer provided by DeterminateSystems has a few advantages:
- It's not written in Bash (it uses Rust, btw)
- Enables the new CLI setup
- Enables the Flake feature
- Provides an uninstall script
To install Nix:
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
Restart your shell and verify that nix --version
works. Secondly, verify
that the new CLI and flake are enabled:
$ nix show-config|grep -i experimental
experimental-features = flakes nix-command
.. kmdo:: ./show-cfg-exp-feature.cmd :caption: Query nix for enabled experimental features :linenos: true
NOTE You want to see the experimental-features
line containing flakes
and nix-command
. The former enables the flake feature itself and the latter
revamps the command-line to follow the new, upcoming format.
Finally, let's try to run something using Nix:
$ LANG=C nix run nixpkgs#cowsay -- "hello nix!"
____________
< hello nix! >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
The first time this command runs, it will take some time to determine, fetch and install all the dependent packages including cowsay itself. Subsequent runs will be much faster, see for yourself!