From 730805ceec67cc29aee0c9e59b2c0f29b98f7c80 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 24 Oct 2026 20:55:36 -0400 Subject: [PATCH] Add a host for a virtual machine for agent coding. --- nix/configuration/flake.nix | 3 + nix/configuration/hosts/robot/DEPLOY_BOOT | 13 +++ nix/configuration/hosts/robot/DEPLOY_SWITCH | 13 +++ nix/configuration/hosts/robot/ISO | 10 ++ nix/configuration/hosts/robot/SELF_BOOT | 10 ++ nix/configuration/hosts/robot/SELF_BUILD | 10 ++ nix/configuration/hosts/robot/SELF_SWITCH | 10 ++ nix/configuration/hosts/robot/VM_ISO | 10 ++ nix/configuration/hosts/robot/default.nix | 98 +++++++++++++++++++ .../hosts/robot/hardware-configuration.nix | 31 ++++++ nix/configuration/hosts/robot/vm_disk.nix | 94 ++++++++++++++++++ 11 files changed, 302 insertions(+) create mode 100755 nix/configuration/hosts/robot/DEPLOY_BOOT create mode 100755 nix/configuration/hosts/robot/DEPLOY_SWITCH create mode 100755 nix/configuration/hosts/robot/ISO create mode 100755 nix/configuration/hosts/robot/SELF_BOOT create mode 100755 nix/configuration/hosts/robot/SELF_BUILD create mode 100755 nix/configuration/hosts/robot/SELF_SWITCH create mode 100755 nix/configuration/hosts/robot/VM_ISO create mode 100644 nix/configuration/hosts/robot/default.nix create mode 100644 nix/configuration/hosts/robot/hardware-configuration.nix create mode 100644 nix/configuration/hosts/robot/vm_disk.nix diff --git a/nix/configuration/flake.nix b/nix/configuration/flake.nix index 4d55e90..d0e7d77 100644 --- a/nix/configuration/flake.nix +++ b/nix/configuration/flake.nix @@ -68,6 +68,9 @@ family_disks = { system = "x86_64-linux"; }; + robot = { + system = "x86_64-linux"; + }; }; nixosConfigs = builtins.mapAttrs ( hostname: nodeConfig: format: diff --git a/nix/configuration/hosts/robot/DEPLOY_BOOT b/nix/configuration/hosts/robot/DEPLOY_BOOT new file mode 100755 index 0000000..ba2c8fc --- /dev/null +++ b/nix/configuration/hosts/robot/DEPLOY_BOOT @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +: "${JOBS:="1"}" + +TARGET=robot + +for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done + +nixos-rebuild boot --flake "$DIR/../../#robot" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json diff --git a/nix/configuration/hosts/robot/DEPLOY_SWITCH b/nix/configuration/hosts/robot/DEPLOY_SWITCH new file mode 100755 index 0000000..cebe5bc --- /dev/null +++ b/nix/configuration/hosts/robot/DEPLOY_SWITCH @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +: "${JOBS:="1"}" + +TARGET=robot + +for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done + +nixos-rebuild switch --flake "$DIR/../../#robot" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json diff --git a/nix/configuration/hosts/robot/ISO b/nix/configuration/hosts/robot/ISO new file mode 100755 index 0000000..4212b11 --- /dev/null +++ b/nix/configuration/hosts/robot/ISO @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +: "${JOBS:="1"}" + +for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done +nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#robot.iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json diff --git a/nix/configuration/hosts/robot/SELF_BOOT b/nix/configuration/hosts/robot/SELF_BOOT new file mode 100755 index 0000000..123894d --- /dev/null +++ b/nix/configuration/hosts/robot/SELF_BOOT @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +: "${JOBS:="1"}" + +for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done +nixos-rebuild boot --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#robot" --log-format internal-json -v "${@}" |& nom --json diff --git a/nix/configuration/hosts/robot/SELF_BUILD b/nix/configuration/hosts/robot/SELF_BUILD new file mode 100755 index 0000000..24bac30 --- /dev/null +++ b/nix/configuration/hosts/robot/SELF_BUILD @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +: "${JOBS:="1"}" + +for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done +nixos-rebuild build --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#robot" --log-format internal-json -v "${@}" |& nom --json diff --git a/nix/configuration/hosts/robot/SELF_SWITCH b/nix/configuration/hosts/robot/SELF_SWITCH new file mode 100755 index 0000000..b39d44b --- /dev/null +++ b/nix/configuration/hosts/robot/SELF_SWITCH @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +: "${JOBS:="1"}" + +for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done +nixos-rebuild switch --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#robot" --log-format internal-json -v "${@}" |& nom --json diff --git a/nix/configuration/hosts/robot/VM_ISO b/nix/configuration/hosts/robot/VM_ISO new file mode 100755 index 0000000..539414c --- /dev/null +++ b/nix/configuration/hosts/robot/VM_ISO @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# +set -euo pipefail +IFS=$'\n\t' +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +: "${JOBS:="1"}" + +for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done +nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#robot.vm_iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json diff --git a/nix/configuration/hosts/robot/default.nix b/nix/configuration/hosts/robot/default.nix new file mode 100644 index 0000000..8ad449e --- /dev/null +++ b/nix/configuration/hosts/robot/default.nix @@ -0,0 +1,98 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + imports = [ + ./hardware-configuration.nix + ./vm_disk.nix + ]; + + config = { + networking = + let + interface = "enp0s10"; + in + { + # Generate with `head -c4 /dev/urandom | od -A none -t x4` + hostId = "5223fba9"; + + hostName = "robot"; # Define your hostname. + + interfaces = { + "${interface}" = { + ipv4.addresses = [ + { + address = "10.215.1.224"; + prefixLength = 24; + } + ]; + + ipv6.addresses = [ + { + address = "2620:11f:7001:7:ffff:ffff:0ad7:01e0"; + prefixLength = 64; + } + ]; + }; + }; + defaultGateway = "10.215.1.1"; + defaultGateway6 = { + # address = "2620:11f:7001:7::1"; + address = "2620:11f:7001:7:ffff:ffff:0ad7:0101"; + inherit interface; + }; + + dhcpcd.enable = lib.mkForce false; + useDHCP = lib.mkForce false; + }; + + time.timeZone = "America/New_York"; + i18n.defaultLocale = "en_US.UTF-8"; + + me.boot.enable = true; + me.boot.secure = false; + me.mountPersistence = true; + boot.loader.timeout = lib.mkForce 0; # We can always generate a new ISO if we need to access other boot options. + + me.optimizations = { + enable = true; + arch = "znver4"; + # build_arch = "x86-64-v3"; + system_features = [ + "gccarch-znver4" + "gccarch-skylake" + "gccarch-kabylake" + # "gccarch-alderlake" missing WAITPKG + "gccarch-x86-64-v3" + "gccarch-x86-64-v4" + "benchmark" + "big-parallel" + "kvm" + "nixos-test" + ]; + }; + + # Mount tmpfs at /tmp + boot.tmp.useTmpfs = true; + + # Enable TRIM + # services.fstrim.enable = lib.mkDefault true; + + # nix.optimise.automatic = true; + # nix.optimise.dates = [ "03:45" ]; + # nix.optimise.persistent = true; + + environment.systemPackages = with pkgs; [ + htop + ]; + + # nix.sshServe.enable = true; + # nix.sshServe.keys = [ "ssh-dss AAAAB3NzaC1k... bob@example.org" ]; + + me.dont_use_substituters.enable = true; + me.minimal_base.enable = true; + }; +} diff --git a/nix/configuration/hosts/robot/hardware-configuration.nix b/nix/configuration/hosts/robot/hardware-configuration.nix new file mode 100644 index 0000000..6029e08 --- /dev/null +++ b/nix/configuration/hosts/robot/hardware-configuration.nix @@ -0,0 +1,31 @@ +{ + config, + lib, + modulesPath, + ... +}: + +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + config = { + boot.initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "thunderbolt" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + # networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true; + }; +} diff --git a/nix/configuration/hosts/robot/vm_disk.nix b/nix/configuration/hosts/robot/vm_disk.nix new file mode 100644 index 0000000..83683f8 --- /dev/null +++ b/nix/configuration/hosts/robot/vm_disk.nix @@ -0,0 +1,94 @@ +{ + config, + lib, + pkgs, + ... +}: + +{ + imports = [ ]; + + config = { + # Mount the local disk + fileSystems = lib.mkIf config.me.mountPersistence { + "/.disk" = lib.mkForce { + device = "/dev/nvme0n1p1"; + fsType = "ext4"; + options = [ + "noatime" + "discard" + ]; + neededForBoot = true; + }; + + "/.persist" = lib.mkForce { + device = "bind9p"; + fsType = "9p"; + options = [ + "noatime" + "trans=virtio" + "version=9p2000.L" + "cache=mmap" + "msize=512000" + # "noauto" + # "x-systemd.automount" + ]; + neededForBoot = true; + }; + + "/persist" = { + fsType = "none"; + device = "/.persist/persist"; + options = [ + "bind" + "rw" + ]; + depends = [ + "/.persist/persist" + ]; + neededForBoot = true; + }; + + "/state" = { + fsType = "none"; + device = "/.persist/state"; + options = [ + "bind" + "rw" + ]; + depends = [ + "/.persist/state" + ]; + neededForBoot = true; + }; + + "/k8spv" = lib.mkForce { + device = "k8spv"; + fsType = "9p"; + options = [ + "noatime" + "trans=virtio" + "version=9p2000.L" + "cache=mmap" + "msize=512000" + # "noauto" + # "x-systemd.automount" + ]; + neededForBoot = true; + }; + + "/disk" = { + fsType = "none"; + device = "/.disk/persist"; + options = [ + "bind" + "rw" + ]; + depends = [ + "/.disk/persist" + ]; + neededForBoot = true; + }; + }; + }; +}