{ lib, config, myvars, ... }: let cfg = config.modules.remote-builders; # Aquamarine - the headless AI inference server (hosts/idols-aquamarine/). # Native x86_64 only: an aarch64 build is faster on the client that needs it # than under qemu-user here (hosts/idols-aquamarine/README.md), and this flake # has no riscv64 output. `aquamarine` is also its SSH alias in # /etc/ssh/ssh_config, and its host key is pinned in # /etc/ssh/ssh_known_hosts (vars/networking.nix). buildMachines = [ { hostName = "aquamarine"; systems = [ "x86_64-linux" ]; # `kvm` stays unadvertised: kvm-only derivations (VM tests) should run on # the client instead of competing with the inference server. supportedFeatures = [ "benchmark" "big-parallel" ]; # root is the daemon's default trusted user on the builder; a normal user # would have to be made root-equivalent there to serve builds. sshUser = "root"; # The daemon's ssh is non-interactive and cannot reach an agent, so the # builder key must be passphrase-free; the agenix key that interactive # logins use is not. Aquamarine authorizes this host key for root # (hosts/idols-aquamarine/default.nix). sshKey = "/etc/ssh/ssh_host_ed25519_key"; inherit (cfg) maxJobs speedFactor; protocol = "ssh-ng"; } ]; in { options.modules.remote-builders = { enable = lib.mkEnableOption "building through aquamarine instead of locally"; # Nix ranks machines by (running jobs + 1) / speedFactor and picks the # lowest. Keeping this below 2 * speedFactor / 3 means the builder is # preferred for every job it has a slot for, while the slot count stays # under its core count and each job may use several cores anyway — part of # the machine is left for what it actually runs (llama-swap). Once the # slots are full, jobs go to the local machine. maxJobs = lib.mkOption { type = lib.types.ints.positive; default = 12; description = "Concurrent builds to run on the builder."; }; speedFactor = lib.mkOption { type = lib.types.numbers.positive; default = 24; description = "Speed of the builder relative to this machine."; }; }; config = lib.mkIf cfg.enable { nix.distributedBuilds = true; nix.buildMachines = buildMachines; }; }