Files
nix-config/modules/nixos/base/remote-builders.nix
T
ryan4yin | 二花 d6450d48a2 feat(remote-builders): build ai and shoukei on aquamarine (#467)
Aquamarine builds for ai and shoukei across the three platforms, with both
daemons logging in as root. They authenticate with their passphrase-free SSH
host keys, and ssh_known_hosts now carries each builder's address.

Assisted-by: DeepSeek Harness 0.2.0-rc.2 (deepseek-flash)
2026-10-17 00:49:22 +08:00

71 lines
2.5 KiB
Nix

{
lib,
config,
myvars,
...
}:
let
cfg = config.modules.remote-builders;
# Aquamarine - the headless AI inference server (hosts/idols-aquamarine/).
# 24C/96G and boot.binfmt emulation for aarch64-linux and riscv64-linux, so it
# serves all three platforms this flake targets. `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" # native
"aarch64-linux" # qemu-user via binfmt
"riscv64-linux" # qemu-user via binfmt
];
# `kvm` is omitted even though aquamarine virtualizes well: a foreign
# derivation requiring it would otherwise be scheduled there and fail under
# emulation instead of falling back to local execution.
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;
};
}