Verifying Nix installation

What’s the simplest, but effective, way to verify that a Nix installation is working properly?

Nix download page has a verify installation section stating:

Check the installation by opening a new terminal and typing:

$ nix-env --version

Nix install process (v2.9.1) ends with:

Try it! Open a new terminal, and type:

$ nix-shell -p nix-info --run "nix-info -m"

Why not just use nix-env --version at the end of the install process?

Frequently I notice said nix-shell command being used everywhere to demonstrate that a nix installation is working or to get its details to apply in another context.

Why not just use nix-info directly?

$ nix-info -m

When using the new experimental commands, would you agree the following alternatives should be suggested?

  • nix --version instead of nix-env --version
  • nix doctor to verify a Nix installation

It’s also strange that nix-info is not mentioned in the Nix Manual Command Reference and I was not able to find equivalence in the new experimental commands.

nix-info is not included with a regular nix installation. It is a separate package in nixpkgs. You can verify this at search.nixos.org. That explains why it is not in the Nix Manual, why there is not a nix-command equivalent, and why it’s necessary to start a shell to use it.

As for the proposed alternatives, nix-command is still unstable, so it might be best not to bifurcate new users until it is stable. Personally, both nix-info and nix doctor don’t work for me because I use flakes and WSL causes shenanigans, respectively.

I’m not sure why someone would use nix-env --version over nix --version. The latter works even when nix-command is disabled.

1 Like

Thanks, I was not aware of that. Indeed it’s a separate package, present in my system, but nix-env says it’s not installed.

$ nix-env -qasP nix-info
-PS  nixpkgs.nix-info         nix-info

Further investigation shows that it’s included in the system $PATH.

$ which nix-info
/run/current-system/sw/bin/nix-info

$echo $PATH
/Users/bob/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/Users/bob/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin

I guess this was a side effect of installing nix-darwin. Nevertheless, it’s strange that nix-env does not recognise nix-info as installed.

It’s true that nix-command and flakes are experimental features and still evolving, yet they seem mature enough and able to lower the entry barrier for novice users. Maybe it’s the right moment to polish the new user’s experience.

The scope of my efforts is focused on macOS with nix, nix-darwin, and home-manager. I hope to identify what works, what does not, and to provide a safe path and guidance especially for non-technical users.

Hosted by Flying Circus.