Files
nixos-setup/hosts/hl-fws1/services/nbot.nix
T
2026-11-12 11:17:21 -05:00

70 lines
2.3 KiB
Nix

{ config, pkgs, skyg-secrets, ... }:
let
homes = "/var/lib/nbot/homes";
goCache = "/var/lib/nbot-cache/go";
settings = {
# The system each container boots (nbot's agent + gh); updated on every rebuild.
system = "${config.skyg.nixos.server.services.nbot-agent.system}";
machines_dir = "/var/lib/machines";
state_dir = "/var/lib/nbot";
agent_cwd = "/root";
idle_timeout = "6h";
max_idle_timeout = "0s";
allow_indefinite = true;
boot_timeout = "2m";
# Go caches shared by all containers on this node (see ABOUTME). Env vars come from the master.
rw_binds = [
"${goCache}/mod:/var/cache/go/mod:idmap"
"${goCache}/build:/var/cache/go/build:idmap"
];
container = { memory_mb = 4096; cpus = 1.0; };
max_container = { memory_mb = 51200; cpus = 6; };
host_reserve = { memory_mb = 8192; cpus = 2.0; };
storage = { min = "2G"; max = "10G"; limit = "50G"; };
drives = [{ path = homes; reserve = "200G"; allow_subdir = true; }];
# Worker of the master on fwdesk. Slack tokens and goose settings come
# from the master. Trusts the first certificate it sees (saved in
# state_dir/master.fingerprint); pin it in master_fingerprint if wanted.
cluster = {
name = "hl-fws1";
master = "wss://fwdesk.lab.internal:7946";
master_fingerprint = [ "ce08c6b0f3aec855cc8b936d81449c1a34074d181089b26acbdddacfca60af1d" ];
};
};
in
{
age.secrets.nbot-cluster = {
file = skyg-secrets.nbot-cluster-hl-fws1;
owner = "root";
mode = "0400";
};
# nbot flake input; options and docs in its repo.
services.nbot = {
enable = true;
mode = "slave";
kvm = true;
drives = [ homes ];
stateDir = "/var/lib/nbot";
configFile = (pkgs.formats.toml { }).generate "nbot.toml" settings;
environmentFile = config.age.secrets.nbot-cluster.path;
};
# Container links belong to systemd-networkd.
networking.networkmanager.unmanaged = [ "interface-name:ve-*" ];
networking.dhcpcd.denyInterfaces = [ "ve-*" ];
# networkd only has the container links here (NetworkManager owns wlan),
# so wait-online would always time out.
systemd.network.wait-online.enable = false;
systemd.tmpfiles.rules = [
"d ${homes} 0700 root root -"
"d ${goCache}/mod 0700 root root -"
"d ${goCache}/build 0700 root root -"
];
}