Speed up your Nix builds with caching
2025-03-24
This is hopefully one of many posts about what I wish I knew when I started using NixOS. I'm not an expert by any stretch of the imagination, so keep in mind that I might be wrong about a lot of this stuff.
Just give me my configuration.nix
If all you want to know is how to pull in the official NixOS caches, here's how:
{ config, pkgs, ... }:
{
nix.settings.substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
];
nix.settings.trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
}
That's going to check the official NixOS cache first, and then the community
Cachix cache. You can add more caches to the substituters
list, and more
public keys to the trusted-public-keys
list.