nixcache: omit substituters that are the host

This commit is contained in:
Colin 2023-03-04 08:09:27 +00:00
parent 386c712a23
commit d7fd7d7368

View File

@ -13,6 +13,7 @@
with lib; with lib;
let let
cfg = config.sane.nixcache; cfg = config.sane.nixcache;
hostName = config.networking.hostName;
in in
{ {
options = { options = {
@ -24,6 +25,16 @@ in
default = config.sane.nixcache.enable; default = config.sane.nixcache.enable;
type = types.bool; type = types.bool;
}; };
sane.nixcache.substituters = mkOption {
type = types.listOf types.string;
default =
(lib.optional (hostName != "servo") "https://nixcache.uninsane.org")
++ (lib.optional (hostName != "desko") "http://desko:5000")
++ [
"https://nix-community.cachix.org"
"https://cache.nixos.org/"
];
};
}; };
config = { config = {
@ -31,12 +42,7 @@ in
# to explicitly build from a specific cache (in case others are down): # to explicitly build from a specific cache (in case others are down):
# - `nixos-rebuild ... --option substituters https://cache.nixos.org` # - `nixos-rebuild ... --option substituters https://cache.nixos.org`
# - `nix build ... --substituters http://desko:5000` # - `nix build ... --substituters http://desko:5000`
nix.settings.substituters = mkIf cfg.enable [ nix.settings.substituters = mkIf cfg.enable cfg.substituters;
"https://nixcache.uninsane.org"
"http://desko:5000"
"https://nix-community.cachix.org"
"https://cache.nixos.org/"
];
# always trust our keys (so one can explicitly use a substituter even if it's not the default # always trust our keys (so one can explicitly use a substituter even if it's not the default
nix.settings.trusted-public-keys = mkIf cfg.enable-trusted-keys [ nix.settings.trusted-public-keys = mkIf cfg.enable-trusted-keys [
"nixcache.uninsane.org:r3WILM6+QrkmsLgqVQcEdibFD7Q/4gyzD9dGT33GP70=" "nixcache.uninsane.org:r3WILM6+QrkmsLgqVQcEdibFD7Q/4gyzD9dGT33GP70="