I have 1 laptop (My-laptop) and 1 PC (My-PC), both of them are using NixOS, and both connected to the same network.
I set up binary cache (nix-serve) on PC as described in nixos wiki for local use, but without the step 3. (nginx).
I use binary cache also described in nixos wiki on My-laptop to use the nix-serve already set up on My-PC. This is my setup on My-laptop:
{
lib,
config,
...
}:
{
nix = {
settings = {
substituters = [
"http://192.168.100.101:5000"
"https://nix-community.cachix.org"
"https://cache.nixos.org/"
];
trusted-public-keys = [
"My-PC-1:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
};
};
}
All are working fine when both machines are running on the same network.
However, when I brought my laptop outside, or when My-PC was shutdown, and do a
nh os switch
on My-laptop, nix complained that it cannot find My-PC and it just stop the process.
The workaround for this situation is explicitly specify the substituters and the trusted-public-keys in the command (to eliminate My-PC substituters):
nh os switch -- --option substituters "https://nix-community.cachix.org https://cache.nixos.org" --option extra-trusted-public-keys "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
I do not know why it is unable to automaticcally fallback to use "https://nix-community.cachix.org"
and "https://cache.nixos.org/"
, is it a bug?
If auto fallback is not possible, why did it let me provide a list of substituters?