2024-08-03 18:28:57 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
2024-07-09 21:42:43 +00:00
|
|
|
let
|
|
|
|
cfg = config.bagel.baremetal.builders;
|
|
|
|
in
|
|
|
|
{
|
2024-08-03 18:28:57 +00:00
|
|
|
imports = [ ./netboot.nix ];
|
|
|
|
|
2024-07-09 21:42:43 +00:00
|
|
|
options = {
|
|
|
|
|
|
|
|
bagel.baremetal.builders = {
|
|
|
|
enable = lib.mkEnableOption "baremetal bagel oven";
|
2024-08-01 20:16:48 +00:00
|
|
|
netboot = lib.mkEnableOption "netboot";
|
2024-07-09 21:42:43 +00:00
|
|
|
num = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
boot.initrd.availableKernelModules = [ "ahci" "ehci_pci" "usb_storage" "usbhid" "sd_mod" ];
|
|
|
|
boot.initrd.kernelModules = [ "dm-snapshot" ];
|
|
|
|
|
2024-07-09 22:55:25 +00:00
|
|
|
users.users.builder = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "nogroup";
|
|
|
|
home = "/var/empty";
|
|
|
|
shell = "/bin/sh";
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
# Do not hardcode Hydra's public key, selectively
|
|
|
|
# add the keys of the coordinators that require us.
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAvUT9YBig9LQPHgypIBHQuC32XqDKxlFZ2CfgDi0ZKx"
|
|
|
|
];
|
|
|
|
};
|
2024-07-17 16:18:59 +00:00
|
|
|
|
|
|
|
users.users.buildbot = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "nogroup";
|
|
|
|
home = "/var/empty";
|
|
|
|
shell = "/bin/sh";
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
# Do not hardcode Buildbot's public key, selectively
|
|
|
|
# add the keys of the coordinators that require us.
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGMnOLLX0vGTZbSJrUmF9ZFXt/NIId/MUrEpXmL2vxod"
|
|
|
|
];
|
|
|
|
};
|
2024-07-30 14:33:47 +00:00
|
|
|
nix.settings = {
|
2024-08-08 08:37:42 +00:00
|
|
|
trusted-users = [ "builder" "buildbot" ];
|
2024-07-30 14:33:47 +00:00
|
|
|
inherit ((import ./assignments.nix).${config.networking.hostName}) max-jobs cores;
|
|
|
|
};
|
2024-07-09 22:55:25 +00:00
|
|
|
|
2024-07-09 21:42:43 +00:00
|
|
|
nixpkgs.hostPlatform = "x86_64-linux";
|
|
|
|
hardware.cpu.intel.updateMicrocode = true;
|
|
|
|
|
|
|
|
boot.loader.systemd-boot.enable = true;
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
boot.initrd.systemd.enable = true;
|
|
|
|
|
|
|
|
boot.initrd.services.lvm.enable = true;
|
|
|
|
|
2024-07-28 17:20:23 +00:00
|
|
|
boot.kernel.sysctl."fs.xfs.xfssyncd_centisecs" = "12000";
|
2024-08-03 16:41:01 +00:00
|
|
|
fileSystems = lib.mkMerge [
|
2024-08-03 18:01:39 +00:00
|
|
|
(lib.mkIf (!cfg.netboot) {
|
2024-08-03 16:41:01 +00:00
|
|
|
"/" = {
|
|
|
|
device = "/dev/disk/by-label/root";
|
|
|
|
fsType = "xfs";
|
|
|
|
};
|
|
|
|
|
|
|
|
"/boot" = {
|
|
|
|
device = "/dev/disk/by-label/BOOT";
|
|
|
|
fsType = "vfat";
|
|
|
|
options = [ "fmask=0022" "dmask=0022" ];
|
|
|
|
};
|
2024-08-03 18:01:39 +00:00
|
|
|
})
|
|
|
|
{
|
2024-08-03 16:41:01 +00:00
|
|
|
"/mnt" = {
|
|
|
|
device = "/dev/disk/by-label/hydra";
|
|
|
|
fsType = "xfs";
|
|
|
|
options = ["logbsize=256k"];
|
|
|
|
};
|
|
|
|
|
|
|
|
# We want the tmp filesystem on the same filesystem as the hydra store, so that builds can use reflinks
|
|
|
|
"/tmp" = {
|
|
|
|
device = "/mnt/tmp";
|
|
|
|
options = [ "bind" ];
|
|
|
|
};
|
2024-08-03 18:01:39 +00:00
|
|
|
}
|
2024-08-03 16:41:01 +00:00
|
|
|
];
|
2024-07-09 21:42:43 +00:00
|
|
|
|
2024-08-03 16:10:59 +00:00
|
|
|
swapDevices = lib.optionals (!cfg.netboot) [
|
2024-07-13 02:40:51 +00:00
|
|
|
{
|
|
|
|
device = "/swapfile";
|
|
|
|
size = 50 * 1024; # 50GiB
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
zramSwap = {
|
|
|
|
enable = true;
|
|
|
|
memoryPercent = 25;
|
|
|
|
};
|
|
|
|
|
2024-07-09 21:42:43 +00:00
|
|
|
boot.kernelParams = [
|
|
|
|
"console=tty1"
|
2024-08-02 11:21:04 +00:00
|
|
|
"console=ttyS0,115200"
|
2024-07-09 21:42:43 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
networking.useNetworkd = true;
|
|
|
|
networking.hostName = "builder-${toString cfg.num}";
|
2024-07-09 22:43:03 +00:00
|
|
|
networking.domain = "wob01.infra.forkos.org";
|
2024-07-09 21:42:43 +00:00
|
|
|
|
|
|
|
systemd.network = {
|
|
|
|
netdevs = {
|
|
|
|
"40-uplink" = {
|
|
|
|
netdevConfig = {
|
|
|
|
Kind = "bond";
|
|
|
|
Name = "uplink";
|
|
|
|
};
|
|
|
|
bondConfig = {
|
|
|
|
Mode = "802.3ad";
|
|
|
|
TransmitHashPolicy = "layer3+4";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
networks = {
|
|
|
|
"40-eno1" = {
|
|
|
|
name = "eno1";
|
|
|
|
bond = [ "uplink" ];
|
|
|
|
};
|
|
|
|
"40-eno2" = {
|
|
|
|
name = "eno2";
|
|
|
|
bond = [ "uplink" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
networking.interfaces.uplink.ipv6.addresses = [
|
|
|
|
{ address = "2a01:584:11::1:${toString cfg.num}"; prefixLength = 64; }
|
|
|
|
];
|
|
|
|
networking.defaultGateway6 = { interface = "uplink"; address = "2a01:584:11::1"; };
|
|
|
|
deployment.targetHost = "2a01:584:11::1:${toString cfg.num}";
|
2024-07-09 22:59:31 +00:00
|
|
|
deployment.tags = [ "builders" ];
|
2024-07-09 21:42:43 +00:00
|
|
|
|
2024-07-11 00:05:58 +00:00
|
|
|
# Why can't we have nice things? https://bugs.openjdk.org/browse/JDK-8170568
|
|
|
|
services.coredns = {
|
|
|
|
enable = true;
|
|
|
|
config = ''
|
|
|
|
. {
|
|
|
|
bind lo
|
|
|
|
forward . 2001:4860:4860::6464
|
|
|
|
template ANY A { rcode NOERROR }
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
services.resolved.enable = false;
|
|
|
|
networking.resolvconf.useLocalResolver = true;
|
|
|
|
|
2024-07-12 19:57:04 +00:00
|
|
|
# Hydra blasts ssh connections and does not multiplex. Loosen some of the
|
|
|
|
# rate limiting.
|
|
|
|
services.openssh.settings = {
|
|
|
|
MaxStartups = "500:30:1000";
|
|
|
|
};
|
|
|
|
|
2024-07-20 13:13:44 +00:00
|
|
|
systemd.services.hydra-gc = {
|
2024-07-26 10:17:04 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2024-07-20 13:13:44 +00:00
|
|
|
description = "Nix Garbage Collector";
|
2024-07-26 10:17:04 +00:00
|
|
|
script = ''
|
|
|
|
while : ; do
|
2024-07-30 11:59:46 +00:00
|
|
|
percent_filled=$(($(stat -f --format="100-(100*%a/%b)" /mnt)))
|
2024-08-20 10:08:49 +00:00
|
|
|
if [ "$percent_filled" -gt "85" ]; then
|
|
|
|
${config.nix.package.out}/bin/nix-store --gc --max-freed 80G --store /mnt
|
2024-07-26 10:17:04 +00:00
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
'';
|
2024-07-20 13:13:44 +00:00
|
|
|
serviceConfig.Type = "oneshot";
|
2024-07-20 14:59:27 +00:00
|
|
|
serviceConfig.User = "builder";
|
2024-07-24 07:35:04 +00:00
|
|
|
};
|
|
|
|
systemd.timers.hydra-gc = {
|
2024-07-26 10:17:04 +00:00
|
|
|
timerConfig.OnUnitInactiveSec = "10min";
|
2024-07-24 07:35:04 +00:00
|
|
|
wantedBy = [ "timers.target" ];
|
2024-07-20 13:13:44 +00:00
|
|
|
};
|
|
|
|
systemd.timers.hydra-gc.timerConfig.Persistent = true;
|
2024-07-09 21:42:43 +00:00
|
|
|
|
|
|
|
bagel.sysadmin.enable = true;
|
|
|
|
|
2024-07-10 14:36:09 +00:00
|
|
|
environment.systemPackages = [ pkgs.ipmitool ];
|
|
|
|
|
2024-07-09 21:42:43 +00:00
|
|
|
system.stateVersion = "24.05";
|
|
|
|
};
|
|
|
|
}
|