Deleting binary caches from configuration

Alternative title: Where does nix get its url sources when performing cache lookups?

It sometimes happens that I want to remove a binary cache that I added to my configuration.nix:

{
  nix.settings.substituters = [
    #"some-cache"
  ];

  nix.settings.trusted-public-keys = [
    #"some-cache-key"
  ];
}

However, when running commands like nix develop or nix-shell, I still see output like:

[0/1 build] downloading 'some-cache'

I find this very confusing as I have:

  • Removed the cache from nix.settings.substituters and run nixos-rebuild.
  • Verified some-cache is not listed in my /etc/nix/nix.conf.
  • Deleted ~/.config/cachix/ directory (so it is not persisted in cachix.dhall).
  • My caches and garbage-collection pages on https://app.cachix.org/ are blank. However there is a reference to a revoked auth token for some-cache.

Indeed I tried what I thought would be the “nuclear option”, namely:

  1. Setting nix.settings.substituters to empty.
  2. Rebuilding and restarting.
  3. Running sudo nix-collect-garbage -d.

Yet I somehow see lookups for all my previous substituters. I feel that I must be misunderstanding something quite badly. Any ideas?

Thanks!

If /etc/nix/nix.conf is changed, make sure you run systemctl restart nix-daemon otherwise Nix daemon doesn’t pick up your new caches.

Ah, thanks for that. I wasn’t aware you could reload changes that way.

That said, unfortunately that does not appear to solve my issue (I imagine a system restart would do that anyway?).

To make it even more direct, I still see the “old” caches used with nix-shell -p hello.

Also it would be great if there was some kind of flag that mentioned which caches were tried; the only method I am aware of is waiting for downloading ... to appear in the console logs, which disappears quite quickly.

nix show-config will show you the effective configuration.

Sadly it will still not show you where each config came from.

Also, in your OP, you didn’t mention ~/.config/nix/nix.conf which might set some things as well.

1 Like

Thanks, ~/.config/nix was exactly the problem! I’m not sure where those files came from, as they don’t appear to be generated by nixos-rebuild, judging by the timestamps / lack of symlinks.

IIRC the cachix CLI creates them under circumstances.

Ah, that seems likely then. Thanks again.