Other languages: fr eo

My personal Nix & NixOS FAQ

Posted on May 24, 2019

I use Nix and NixOS every day, but I still feel frustrated because I don't know how to perform some basic tasks. I have decided to put the questions I ask myself on this page, and hopefully fill in the answers little by little. This will serve both as a future reference (to me and others) and as a motivation to learn to use Nix properly.

Please do not hesitate to contact me to suggest answers or improvements.

Many thanks to Andrew Miloradovsky and Daniel Barlow for their answers.

How can I build a package locally instead of downloading the binary?

Add --option substitute false, or set it globally. (search man nix.conf for “substitute”).

How can I get the Nix directory (containing the code and Nix files) of a package?

Here I simply copy Andrew Miloradovsy's answer:

It's all in ~/.nix-defexpr/channels_root/nixos/, or in the user's own channel(s). See there pkgs/top-level/all-packages.nix, where all the “packages” have to be registered: some are paths to an actual file with a Nix-expression, some are functions, generating the “packages” for each combination of inputs.

But you can't/shouldn't edit those. Clone the Nixpkgs repository instead and edit it in there.

How to find the Nix store path associated to an installed package?

If the package installed the command <command> in the PATH, you can do:

$ realpath `which <command>`

Otherwise, you can use nix-build for this (though it has the side-effect of downloading/building the package if you didn't have it already, it won't add it to your current environment, so no practical difference except disk space).

$ nix-build '<nixpkgs>' -A hello
/nix/store/20liz5dns3dm13gbk5synzf5qjsdpf51-hello-2.10

Is there a command to delete a specific derivation from the Nix store?

To be filled

If an error occurs during the upgrading of a package, how can I temporarily ignore this package's updates in order to upgrade the rest of the packages?

To be filled