Files

96 lines
3.0 KiB
Nix
Raw Permalink Normal View History

2025-03-20 10:45:16 -05:00
{
2025-05-29 10:48:46 -05:00
config,
2025-06-10 14:28:46 -05:00
lib,
2025-12-16 16:48:11 -06:00
metadata,
2025-06-10 14:28:46 -05:00
pkgs,
2025-03-20 10:45:16 -05:00
...
}:
2025-02-04 07:44:54 -06:00
2025-05-29 10:48:46 -05:00
let
2025-12-16 16:48:11 -06:00
builderHosts = lib.filterAttrs (_n: v: (builtins.hasAttr "builder" v) && v.builder) metadata.hosts;
2025-05-29 10:48:46 -05:00
cfg = config.greg.nix;
hostname = x: if cfg.cache then "${x}.shire-zebra.ts.net" else "${x}.thehellings.lan";
2025-05-29 10:48:46 -05:00
in
2025-02-04 07:44:54 -06:00
{
2025-05-29 10:48:46 -05:00
options.greg.nix = {
cache = lib.mkOption {
type = lib.types.bool;
default = true;
2025-02-04 07:44:54 -06:00
};
};
2025-05-29 10:48:46 -05:00
config = {
2025-12-16 16:48:11 -06:00
programs.ssh.extraConfig = builtins.concatStringsSep "\n" (
lib.map (x: ''
Host ${x}-builder
Hostname ${hostname x}
2025-12-16 16:48:11 -06:00
User remote-builder-user
'') (lib.attrNames builderHosts)
);
2025-05-29 10:48:46 -05:00
nix = {
2025-12-16 16:48:11 -06:00
buildMachines = lib.mapAttrsToList (k: v: {
inherit (v) systems;
2025-12-25 22:53:55 -06:00
hostName = "${k}-builder";
protocol = "ssh-ng";
2025-12-16 16:48:11 -06:00
}) builderHosts;
distributedBuilds = true;
2025-05-29 10:48:46 -05:00
gc = {
automatic = true;
# Scheduling of them is different in nixos vs nix-darwin, so check for
# the extra details there
options = "--delete-older-than 30d";
};
2025-11-08 16:01:21 -06:00
package = pkgs.nixVersions.stable;
2025-05-29 10:48:46 -05:00
settings = {
builders-use-substitutes = true;
2025-05-29 10:48:46 -05:00
cores = 0; # Use all cores for builds
download-buffer-size = 500 * 1024 * 1024;
experimental-features = "nix-command flakes";
keep-outputs = true;
keep-derivations = true;
min-free = (toString (1024 * 1024 * 1024));
max-free = (toString (5 * 1024 * 1024 * 1024));
trusted-users = [
"greg"
"gregory.hellings"
]; # For home and for work machines
substituters =
2026-05-10 01:48:45 -05:00
(
if cfg.cache then
[
#"http://chronicles.shire-zebra.ts.net:9000/binary-cache/"
2026-07-25 11:40:35 -05:00
"http://niks3.nas1.shire-zebra.ts.net:30189/"
2026-05-12 21:25:24 -05:00
#"http://nas1.shire-zebra.ts.net:8080/default"
2026-05-10 01:48:45 -05:00
]
else
[
2026-07-25 11:40:35 -05:00
"http://niks3.nas1.thehellings.lan:30189/"
2026-05-10 01:48:45 -05:00
]
)
2025-05-29 10:48:46 -05:00
++ [
"https://ai.cachix.org"
"https://nixpkgs-python.cachix.org"
"https://greg-hellings.cachix.org"
"https://nix-community.cachix.org"
"https://cache.nixos.org"
2025-09-11 23:00:19 -05:00
"https://nixhelm.cachix.org"
2025-05-29 10:48:46 -05:00
];
trusted-public-keys = [
2026-05-12 21:25:24 -05:00
"niks3:8iztr/NACwYEK5O7JJtGFGuv+ho/cmwql8NeoCiXNto="
2026-02-09 23:41:30 -06:00
#"chronicles.shire-zebra.ts.net:0qWYHn3gGllXChhAaaxKlNZtRy6yG/XJs1RFSqV3nW8="
2025-10-16 23:21:14 -05:00
"default:DTGxNijw2D8FrZJPT1pFTWcLqbt60tovL+9Z+VW0HRY="
2025-05-29 10:48:46 -05:00
"ai.cachix.org-1:N9dzRK+alWwoKXQlnn0H6aUx0lU/mspIoz8hMvGvbbc="
"nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU="
"greg-hellings.cachix.org-1:y01Jl/L5evlhxdnUW6n56AiI1k8g1wxWhTxJCe7XSco="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
2025-09-11 23:00:19 -05:00
"nixhelm.cachix.org-1:esqauAsR4opRF0UsGrA6H3gD21OrzMnBBYvJXeddjtY="
2025-05-29 10:48:46 -05:00
];
};
};
2025-02-04 07:44:54 -06:00
};
}