Skip to content

Setup

The official install script is available at NixOS, but the installer provided by DeterminateSystems has a few advantages:

  1. It's not written in Bash (it uses Rust, btw)
  2. Enables the new CLI setup
  3. Enables the Flake feature
  4. Provides an uninstall script

To install Nix:

Run Nix Installer
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:

Query nix for enabled experimental features
$ 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:

run cowsay 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!