From 8713cd3c58c4cac32372f10ffdcbec7a5a350630 Mon Sep 17 00:00:00 2001
From: zowoq <59103226+zowoq@users.noreply.github.com>
Date: Thu, 14 Dec 2023 09:39:50 +1000
Subject: [PATCH] build04: switch to new hardware

---
 devdoc/hosts.md                           | 10 +--
 docs/continuous-integration.md            |  2 +-
 hosts/build04/configuration.nix           | 42 ++-----------
 hosts/build04/hardware-configuration.nix  | 77 -----------------------
 modules/nixos/remote-workers.nix          |  3 +-
 terraform/cloudflare_nix-community_org.tf |  4 +-
 6 files changed, 14 insertions(+), 124 deletions(-)
 delete mode 100644 hosts/build04/hardware-configuration.nix

diff --git a/devdoc/hosts.md b/devdoc/hosts.md
index b9e8d5b..5225435 100644
--- a/devdoc/hosts.md
+++ b/devdoc/hosts.md
@@ -24,11 +24,11 @@
 
 ### `build04`
 
-- Provider: Oracle cloud
-- Instance type: [Ampere A1 Compute](https://www.oracle.com/cloud/compute/arm/)
-- CPU: 4 VCPUs on an Ampere Altra (arm64)
-- RAM: 24GB
-- Drives: 200 GB Block
+- Provider: Hetzner
+- Instance type: [RX170](https://www.hetzner.com/dedicated-rootserver/rx170)
+- CPU: Ampere Altra Q80-30 80-Core Processor
+- RAM: 128GB DDR4 ECC
+- Drives: 2 x 960 GB NVME in RAID 0
 
 ### `darwin02`
 
diff --git a/docs/continuous-integration.md b/docs/continuous-integration.md
index 578d484..e751297 100644
--- a/docs/continuous-integration.md
+++ b/docs/continuous-integration.md
@@ -5,7 +5,7 @@ We provide CI for these platforms:
 - `x86_64-darwin`
 - `x86_64-linux`
 
-We only have limited build capacity for `*-darwin` and `aarch64-linux` so please don't use it excessively.
+We only have limited build capacity for `*-darwin` so please don't use it excessively.
 
 #### Buildbot
 
diff --git a/hosts/build04/configuration.nix b/hosts/build04/configuration.nix
index e19fa34..2a4a563 100644
--- a/hosts/build04/configuration.nix
+++ b/hosts/build04/configuration.nix
@@ -1,51 +1,19 @@
 { inputs, ... }:
 {
   imports = [
-    inputs.disko.nixosModules.disko
-    ./hardware-configuration.nix
+    inputs.srvos.nixosModules.hardware-hetzner-online-arm
+    inputs.self.nixosModules.disko-raid
     inputs.self.nixosModules.common
     inputs.self.nixosModules.builder
     inputs.self.nixosModules.hercules-ci
     inputs.self.nixosModules.remote-builder
   ];
 
-  nixCommunity.gc.gbFree = 25;
-
-  # disable kvm/nixos-tests
-  nix.settings.system-features = [ "big-parallel" ];
-
-  boot.loader.systemd-boot.enable = true;
-  boot.loader.systemd-boot.configurationLimit = 3;
-  boot.loader.efi.canTouchEfiVariables = false;
-
-  # Make it easier to recover via serial console in case something goes wrong.
-  services.getty.autologinUser = "root";
+  nixCommunity.disko.raidLevel = 0; # more disk space, we don't have much state to restore anyway
 
   networking.hostName = "build04";
-  networking.hostId = "8daf74c0";
 
-  # enabled by default for stateVersion < 23.11
-  boot.swraid.enable = false;
+  system.stateVersion = "23.11";
 
-  system.stateVersion = "21.11";
-  systemd.network = {
-    enable = true;
-    networks.ethernet.extraConfig = ''
-      [Match]
-      Type = ether
-      [Network]
-      DHCP = yes
-      IPv6AcceptRA = true
-      # Usually dhcpv6 should give us a public address, but it doesn't seem to work for oracle with both networkd/dhcpcd
-      # so we set it manually here. One can get the address by clicking on the primary vnic in the oracle console and
-      # under Resources -> IPv6 Addresses
-      Address = 2603:c022:c001:b500:f1d4:5343:e8ce:d6ba
-    '';
-  };
+  systemd.network.networks."10-uplink".networkConfig.Address = "2a01:4f9:3051:3962::2";
 }
-
-## `opc` is the username from the oracle image. Replace with root if we are booted into nixos.
-# nix run --inputs-from . nixpkgs#nixos-anywhere -- \
-#   --debug \
-#   --flake '.#build04' \
-#   opc@141.148.235.248
diff --git a/hosts/build04/hardware-configuration.nix b/hosts/build04/hardware-configuration.nix
deleted file mode 100644
index e20e992..0000000
--- a/hosts/build04/hardware-configuration.nix
+++ /dev/null
@@ -1,77 +0,0 @@
-# Do not modify this file!  It was generated by ‘nixos-generate-config’
-# and may be overwritten by future invocations.  Please make changes
-# to /etc/nixos/configuration.nix instead.
-{ modulesPath
-, ...
-}: {
-  imports = [
-    (modulesPath + "/profiles/qemu-guest.nix")
-  ];
-
-  boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_pci" ];
-  boot.initrd.kernelModules = [ ];
-  boot.kernelModules = [ ];
-  boot.extraModulePackages = [ ];
-
-  disko.devices = {
-    disk = {
-      sda = {
-        type = "disk";
-        device = "/dev/sda";
-        content = {
-          type = "table";
-          format = "gpt";
-          partitions = [
-            {
-              name = "ESP";
-              start = "0";
-              end = "1GiB";
-              fs-type = "fat32";
-              bootable = true;
-              content = {
-                type = "filesystem";
-                format = "vfat";
-                mountpoint = "/boot";
-              };
-            }
-            {
-              name = "zfs";
-              start = "1GiB";
-              end = "100%";
-              content = {
-                type = "zfs";
-                pool = "zroot";
-              };
-            }
-          ];
-        };
-      };
-    };
-    zpool = {
-      zroot = {
-        type = "zpool";
-        rootFsOptions = {
-          compression = "lz4";
-          "com.sun:auto-snapshot" = "false";
-        };
-
-        datasets = {
-          "root" = {
-            type = "zfs_fs";
-            mountpoint = null;
-          };
-          "root/nixos" = {
-            type = "zfs_fs";
-            mountpoint = "/";
-          };
-          "root/home" = {
-            type = "zfs_fs";
-            mountpoint = "/home";
-          };
-        };
-      };
-    };
-  };
-
-  swapDevices = [ ];
-}
diff --git a/modules/nixos/remote-workers.nix b/modules/nixos/remote-workers.nix
index fe099e5..9ac5d32 100644
--- a/modules/nixos/remote-workers.nix
+++ b/modules/nixos/remote-workers.nix
@@ -7,12 +7,11 @@
     # these machines are used by hydra which doesn't support ssh-ng
     {
       hostName = "build04.nix-community.org";
-      maxJobs = 4;
+      maxJobs = 80;
       protocol = "ssh";
       sshKey = config.sops.secrets.id_buildfarm.path;
       sshUser = "nix";
       system = "aarch64-linux";
-      supportedFeatures = [ "big-parallel" ];
     }
     {
       hostName = "darwin02.nix-community.org";
diff --git a/terraform/cloudflare_nix-community_org.tf b/terraform/cloudflare_nix-community_org.tf
index dfa4c3c..e5757a7 100644
--- a/terraform/cloudflare_nix-community_org.tf
+++ b/terraform/cloudflare_nix-community_org.tf
@@ -64,14 +64,14 @@ resource "cloudflare_record" "nix-community-org-build03-AAAA" {
 resource "cloudflare_record" "nix-community-org-build04-A" {
   zone_id = local.nix_community_zone_id
   name    = "build04"
-  value   = "141.144.201.31"
+  value   = "65.109.107.32"
   type    = "A"
 }
 
 resource "cloudflare_record" "nix-community-org-build04-AAAA" {
   zone_id = local.nix_community_zone_id
   name    = "build04"
-  value   = "2603:c022:c001:b500:f1d4:5343:e8ce:d6ba"
+  value   = "2a01:4f9:3051:3962::2"
   type    = "AAAA"
 }