Updated October 3, 2024
Updated with help from @poz and others who have reached out with suggestions.
I’ve now been using Nix, the package manager, fulltime on my personal machines since 2021. I run NixOS on my personal desktop/laptop and VMs, so I have some reasonable experience using it.
I really enjoy using Nix, and think it’s a very useful tool, but it definitely needs a lot of tweaking.
Today I want to share some of the config settings in Nix that most users probably want to change. The defaults that Nix uses for these settings don’t make that much sense to me, and most people who actually use Nix should probably consider changing them.
Any suggested changes since this was published a year prior?
While not a “default setting”, a thing I always suggest is to avoid setting multiple substituters in your config. Instead, set trusted-substituters and trusted-public-keys, and then only set the substituters you need in the nixConfig.substituters attribute of the flake.nix of the project they are needed in (if you’re not using flakes, add a .nix.conf file to your project and export NIX_USER_CONF_FILES="${NIX_USER_CONF_FILES+$XDG_CONFIG_HOME/nix}:$PWD/.nix.conf" to your .envrc)
That’s a good one. Definitely seems selecting substituters closer to runtime is more flexible. Especially when the system may be roaming across networks like a laptop that may move outside your home LAN that links to your local desktop cache.
While not a “default setting”, a thing I always suggest is to avoid setting multiple
substituters
in your config. Instead, settrusted-substituters
andtrusted-public-keys
, and then only set the substituters you need in thenixConfig.substituters
attribute of theflake.nix
of the project they are needed in (if you’re not using flakes, add a.nix.conf
file to your project andexport NIX_USER_CONF_FILES="${NIX_USER_CONF_FILES+$XDG_CONFIG_HOME/nix}:$PWD/.nix.conf"
to your.envrc
)That’s a good one. Definitely seems selecting substituters closer to runtime is more flexible. Especially when the system may be roaming across networks like a laptop that may move outside your home LAN that links to your local desktop cache.