2022-10-24 13:20:22 +00:00
|
|
|
# speed up builds from e.g. moby or lappy by having them query desko and servo first.
|
|
|
|
# if one of these hosts is offline, instead manually specify just cachix:
|
|
|
|
# - `nixos-rebuild --option substituters https://cache.nixos.org/`
|
|
|
|
#
|
|
|
|
# future improvements:
|
|
|
|
# - apply for community arm build box:
|
|
|
|
# - <https://github.com/nix-community/aarch64-build-box>
|
|
|
|
# - don't require all substituters to be online:
|
|
|
|
# - <https://github.com/NixOS/nix/pull/7188>
|
|
|
|
|
2022-06-28 10:44:10 +00:00
|
|
|
{ lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
2022-08-01 07:23:49 +00:00
|
|
|
cfg = config.sane.nixcache;
|
2023-03-04 08:09:27 +00:00
|
|
|
hostName = config.networking.hostName;
|
2022-06-28 10:44:10 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2022-08-01 07:23:49 +00:00
|
|
|
sane.nixcache.enable = mkOption {
|
2022-06-28 10:44:10 +00:00
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
2022-11-22 03:07:11 +00:00
|
|
|
sane.nixcache.enable-trusted-keys = mkOption {
|
|
|
|
default = config.sane.nixcache.enable;
|
|
|
|
type = types.bool;
|
|
|
|
};
|
2023-03-04 08:09:27 +00:00
|
|
|
sane.nixcache.substituters = mkOption {
|
2023-05-31 04:27:27 +00:00
|
|
|
type = types.listOf types.str;
|
2023-03-04 08:09:27 +00:00
|
|
|
default =
|
2023-03-11 13:45:45 +00:00
|
|
|
# TODO: make these blacklisted entries injectable
|
2023-03-04 08:09:27 +00:00
|
|
|
(lib.optional (hostName != "servo") "https://nixcache.uninsane.org")
|
2023-03-11 13:45:45 +00:00
|
|
|
++ (lib.optional (hostName != "servo" && hostName != "desko") "http://desko:5000")
|
2023-03-04 08:09:27 +00:00
|
|
|
++ [
|
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
"https://cache.nixos.org/"
|
|
|
|
];
|
|
|
|
};
|
2022-06-28 10:44:10 +00:00
|
|
|
};
|
|
|
|
|
2022-11-06 03:13:17 +00:00
|
|
|
config = {
|
2022-06-28 10:44:10 +00:00
|
|
|
# use our own binary cache
|
2022-11-06 11:47:10 +00:00
|
|
|
# to explicitly build from a specific cache (in case others are down):
|
|
|
|
# - `nixos-rebuild ... --option substituters https://cache.nixos.org`
|
|
|
|
# - `nix build ... --substituters http://desko:5000`
|
2023-03-04 08:09:27 +00:00
|
|
|
nix.settings.substituters = mkIf cfg.enable cfg.substituters;
|
2022-11-06 03:13:17 +00:00
|
|
|
# always trust our keys (so one can explicitly use a substituter even if it's not the default
|
2022-11-22 03:07:11 +00:00
|
|
|
nix.settings.trusted-public-keys = mkIf cfg.enable-trusted-keys [
|
2022-11-06 03:13:17 +00:00
|
|
|
"nixcache.uninsane.org:r3WILM6+QrkmsLgqVQcEdibFD7Q/4gyzD9dGT33GP70="
|
|
|
|
"desko:Q7mjjqoBMgNQ5P0e63sLur65A+D4f3Sv4QiycDIKxiI="
|
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
|
|
];
|
2022-06-28 10:44:10 +00:00
|
|
|
};
|
|
|
|
}
|