How to use binary cache in NixOS

/etc/nix/nix.conf should be a symlink on nixOS, pointing to a file in the store, generated from what you have set in your /etc/nixos/configuration.nix. Most of the nix.* options affect the /etc/nix/nix.conf, therefore you shouldn’t edit it by hand ever on NixOS.

And as soon as you added the aforementioned options and rebuild/switched, the caches are considered. It should roughly look like this:

They work. Though they probably do not have what you need. It is easy to provide a cache (thannks to cachix) and push random builds to it. Though its hard to actually provide recent versions of the builds that match the inputs of recent nixpkgs, and perhaps older nixpkgs as well, sonsidering overlays…

So if you want to use some overlay that pushes to a binary cache, make sure that you use the exact same version of nixpkgs as they used to build and push from the artifacts.

As soon as you have even the slightest input different then they had to populate the cache, then your hash will change and therefore you wont get anything from the cache anymore.

On top of that, nix caches negative lookup for binary caches, so if nix already knows that an output is not available in a cache, it won’t ask that cache again for the next hour or so.

Personally I prefer to have as little trusted users as possible, as a trusted user can change nix configuration on the fly and also they can add unsigned pathes to the store.

Though if you are the only user anyway, I don’t think it can harm much.

Changing /etc/nixos/configuration.nix does nothing, only running nixos-rebuild switch or nixos-rebuild test will actually activate the new configuration. test will make it disappear after a boot, switch wil make it persist the boot, and then there is nixos-rebuild boot which will build and make it the default after next boot, but until then you remain in your previous version of the system configuration.