5 Commits

Author SHA1 Message Date
Tom Alexander
2ea1f9a11d Fix building packages on my builder VM. 2026-11-20 13:29:46 -05:00
Tom Alexander
c1e25b0365 Merge branch 'robot' into nix 2026-11-20 13:26:37 -05:00
Tom Alexander
6d35630589 Add a host for a virtual machine for agent coding. 2026-11-19 17:16:43 -05:00
Tom Alexander
fd5b247408 Add a wip_kubernetes build target for nix_builder. 2026-11-12 15:56:03 -05:00
Tom Alexander
bd03c5ec08 Disable firefox's disk cache and limit memory usage. 2026-11-12 15:38:02 -05:00
23 changed files with 530 additions and 5 deletions

View File

@@ -79,6 +79,7 @@ in
./roles/openpgp_card_tools ./roles/openpgp_card_tools
./roles/optimized_build ./roles/optimized_build
./roles/pcsx2 ./roles/pcsx2
./roles/pi_coding_agent
./roles/podman ./roles/podman
./roles/postgresql_client ./roles/postgresql_client
./roles/python ./roles/python
@@ -86,6 +87,7 @@ in
./roles/rdp_client ./roles/rdp_client
./roles/recovery ./roles/recovery
./roles/reset ./roles/reset
./roles/robot
./roles/rpcs3 ./roles/rpcs3
./roles/rust ./roles/rust
./roles/sequoia ./roles/sequoia
@@ -287,6 +289,13 @@ in
(disableOptimizations "nototools") # Needs to use the same version of python as the zopfli package (disableOptimizations "nototools") # Needs to use the same version of python as the zopfli package
(disableOptimizations "lib2geom") # Tests failing: ellipse-test, elliptical-arc-test, line-test, polynomial-test (disableOptimizations "lib2geom") # Tests failing: ellipse-test, elliptical-arc-test, line-test, polynomial-test
(disableOptimizations "libjpeg_turbo") # Test failing: djpeg12-shared-3x2-float-prog-cmp (disableOptimizations "libjpeg_turbo") # Test failing: djpeg12-shared-3x2-float-prog-cmp
(disableOptimizations "libjxl") # Test failing, but only on my builder VM. I assume related to AVX512: DjxlFuzzerTestInstantiation
(disableOptimizationsScope "kdePackages" "qtbase") # Issue with my bhyve VM: Incompatible processor. This Qt build requires the following features: avx512ifma avx512vbmi avx512vbmi2 gfni avx512bitalg avx512vpopcntdq
(disableOptimizationsScope "libsForQt5" "qtbase") # Issue with my bhyve VM: Incompatible processor. This Qt build requires the following features: avx512ifma avx512vbmi avx512vbmi2 gfni avx512bitalg avx512vpopcntdq
(disableOptimizationsScope "qt6Packages" "qtbase") # Issue with my bhyve VM: Incompatible processor. This Qt build requires the following features: avx512ifma avx512vbmi avx512vbmi2 gfni avx512bitalg avx512vpopcntdq
(disableTests "sequoia-sq") # Test failing on my builder vm: sq_key_generate_dev_null
(disableOptimizations "tzdata") # Tests failing on my builder vm
(disableOptimizations "simdutf") # Tests failing on my builder vm
]; ];
hardware.firmware = hardware.firmware =

View File

@@ -75,6 +75,9 @@
family_disks = { family_disks = {
system = "x86_64-linux"; system = "x86_64-linux";
}; };
robot = {
system = "x86_64-linux";
};
}; };
baseConfig = nixpkgs.lib.nixosSystem { baseConfig = nixpkgs.lib.nixosSystem {
specialArgs = { specialArgs = {
@@ -154,7 +157,14 @@
// { // {
wip = nixpkgs.legacyPackages."${system}".symlinkJoin { wip = nixpkgs.legacyPackages."${system}".symlinkJoin {
name = "wip"; name = "wip";
paths = [ self.nixosConfigurations."odo".config.system.build.toplevel ]; paths =
(builtins.map (name: self.nixosConfigurations."${name}".config.system.build.toplevel) [
"odo"
"odowork"
"quark"
"family_disks"
])
++ [ self.packages."${system}".hydra.vm_iso ];
}; };
} }
) )

View File

@@ -137,6 +137,7 @@
me.python.enable = true; me.python.enable = true;
me.qemu.enable = true; me.qemu.enable = true;
me.recovery.enable = true; me.recovery.enable = true;
me.robot.enable = true;
me.rpcs3.enable = true; me.rpcs3.enable = true;
me.rust.enable = true; me.rust.enable = true;
me.sequoia.enable = true; me.sequoia.enable = true;

View File

@@ -128,6 +128,7 @@
me.postgresql_client.enable = true; me.postgresql_client.enable = true;
me.python.enable = true; me.python.enable = true;
me.rdp_client.enable = true; me.rdp_client.enable = true;
me.robot.enable = true;
me.rust.enable = true; me.rust.enable = true;
me.sequoia.enable = true; me.sequoia.enable = true;
me.shikane.enable = true; me.shikane.enable = true;

View File

@@ -128,6 +128,7 @@
me.python.enable = true; me.python.enable = true;
me.qemu.enable = true; me.qemu.enable = true;
me.recovery.enable = true; me.recovery.enable = true;
me.robot.enable = true;
me.rpcs3.enable = true; me.rpcs3.enable = true;
me.rust.enable = true; me.rust.enable = true;
me.sequoia.enable = true; me.sequoia.enable = true;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,81 @@
{
config,
lib,
pkgs,
...
}:
{
imports = [
./hardware-configuration.nix
./vm_disk.nix
];
config = {
networking =
let
interface = "ens3";
in
{
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
hostId = "5223fba9";
hostName = "robot"; # Define your hostname.
# These are both enabled by default, but putting it explicitly here anyway. We will get networking via qemu's slirp.
dhcpcd.enable = true;
useDHCP = true;
};
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;
# For console-only qemu operation
boot.kernelParams = [
"console=ttyS0,115200n8"
];
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;
me.pi_coding_agent.enable = true;
};
}

View File

@@ -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.<interface>.useDHCP`.
# networking.useDHCP = lib.mkDefault true;
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true;
};
}

View File

@@ -0,0 +1,56 @@
{
config,
lib,
pkgs,
...
}:
{
imports = [ ];
config = {
# Mount the local disk
fileSystems = lib.mkIf config.me.mountPersistence {
"/persist" = {
fsType = "none";
device = "/robot/.persist";
options = [
"bind"
"rw"
];
depends = [
"/robot/.persist"
];
neededForBoot = true;
};
"/state" = {
fsType = "none";
device = "/robot/.state";
options = [
"bind"
"rw"
];
depends = [
"/robot/.state"
];
neededForBoot = true;
};
"/robot" = lib.mkForce {
device = "host";
fsType = "9p";
options = [
"noatime"
"trans=virtio"
"version=9p2000.L"
"cache=mmap"
"msize=512000"
# "noauto"
# "x-systemd.automount"
];
neededForBoot = true;
};
};
};
}

View File

@@ -76,5 +76,15 @@ in
# Disable installing documentation. # Disable installing documentation.
documentation.doc.enable = false; documentation.doc.enable = false;
documentation.nixos.enable = false; documentation.nixos.enable = false;
# Let users in group wheel increase the priority of their processees without elevating to root.
security.pam.loginLimits = [
{
domain = "@wheel";
type = "-"; # Sets both soft and hard limits
item = "nice";
value = -20; # Range is -20 (highest priority) to 19 (lowest)
}
];
}; };
} }

View File

@@ -84,6 +84,13 @@
"browser.ml.enable" = false; "browser.ml.enable" = false;
"browser.ml.chat.enabled" = false; "browser.ml.chat.enabled" = false;
"browser.ml.chat.menu" = false; "browser.ml.chat.menu" = false;
# Disable disk-based caching to reduce writes to SSDs. My machines have plenty of RAM.
"browser.cache.disk.enable" = 0;
# Max memory for cache in KiB (set to 1 GiB). This defaults to unbounded (-1).
"browser.cache.memory.capacity" = 1048576;
# Only keep the previous 5 pages in memory for the back button. This defaults to unbounded (-1).
"browser.sessionhistory.max_total_viewers" = 5;
}; };
# Check about:policies#documentation and https://mozilla.github.io/policy-templates/ for options. # Check about:policies#documentation and https://mozilla.github.io/policy-templates/ for options.
policies = { policies = {

View File

@@ -81,6 +81,7 @@ in
let let
enabled_targets = [ enabled_targets = [
"wip" "wip"
"wip_kubernetes"
"odo" "odo"
"odo_update" "odo_update"
"odowork" "odowork"

View File

@@ -7,6 +7,13 @@ output_directory = "/home/nixworker/persist/nix_builder"
path = "nix/configuration" path = "nix/configuration"
attr = "wip" attr = "wip"
[[targets]]
name = "wip_kubernetes"
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
branch = "wip"
path = "nix/kubernetes"
attr = "wip"
[[targets]] [[targets]]
name = "odo" name = "odo"
repo = "https://code.fizz.buzz/talexander/machine_setup.git" repo = "https://code.fizz.buzz/talexander/machine_setup.git"

View File

@@ -0,0 +1,67 @@
# Example endpoint when run in qemu with slirp: http://10.0.2.2:8080/v1/chat/completions
{
config,
lib,
pkgs,
...
}:
{
imports = [ ];
options.me = {
pi_coding_agent.enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Whether we want to install pi_coding_agent.";
};
};
config = lib.mkIf config.me.pi_coding_agent.enable {
environment.systemPackages = with pkgs; [
pi-coding-agent
];
nixpkgs.overlays = [
(final: prev: {
pi-coding-agent = pkgs.symlinkJoin {
name = prev.pi-coding-agent.name;
paths = [ prev.pi-coding-agent ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/pi \
--set-default PI_SKIP_VERSION_CHECK 1 \
--set-default PI_TELEMETRY 0 \
--set-default PI_OFFLINE 1 \
--set-default LLAMA_BASE_URL http://10.0.2.2:8080 \
--set-default LLAMA_API_KEY optional-secret \
--set-default PI_PROVIDER llama.cpp \
--set-default PI_MODEL qwen3.8_27b_bf16
'';
};
})
];
environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) {
hideMounts = true;
users.talexander = {
directories = [
{
directory = ".pi";
user = "talexander";
group = "talexander";
mode = "0700";
}
{
# For ~/.agents/skills
directory = ".agents";
user = "talexander";
group = "talexander";
mode = "0700";
}
];
};
};
};
}

View File

@@ -0,0 +1,81 @@
{
config,
lib,
pkgs,
self,
...
}:
let
patchScriptBin =
filename: contents:
((pkgs.writeScriptBin filename contents).overrideAttrs (old: {
buildCommand = "${old.buildCommand}\n patchShebangs $out";
}));
launch_robot_script = (
patchScriptBin "launch_robot" (
builtins.readFile (
pkgs.replaceVars ./files/robot/launch_robot.bash (
let
robot_image_package = self.packages.${pkgs.system}.robot.vm_iso;
robot_image = "${robot_image_package}/iso/${robot_image_package.isoName}";
in
{
"OVMFfd" = "${pkgs.OVMF.fd}";
"mountiso" = robot_image;
}
)
)
)
);
launch_robot_script_wrapped =
(pkgs.writeScriptBin "launch_robot" ''
#!/usr/bin/env bash
export "PATH=${
pkgs.lib.makeBinPath (
with pkgs;
[
qemu
]
)
}:''${PATH}"
exec ${launch_robot_script}/bin/launch_robot "''${@}"
'').overrideAttrs
(old: {
buildCommand = ''
${old.buildCommand}
patchShebangs $out
'';
});
in
{
imports = [ ];
options.me = {
robot.enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Whether we want to install robot.";
};
};
config = lib.mkIf config.me.robot.enable {
environment.systemPackages = with pkgs; [
launch_robot_script_wrapped
];
environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) {
hideMounts = true;
directories = [
{
directory = "/robot";
user = "talexander";
group = "talexander";
mode = "0700";
}
];
};
};
}

View File

@@ -0,0 +1,85 @@
#!/usr/bin/env bash
#
# Launch the robot virtual machine
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
: ${CPU_CORES:="4"}
: ${MEMORY:="8G"}
: ${GTK_ENABLE:="NO"} # Only enable one, either GTK or VNC
: ${VNC_ENABLE:="NO"} # Only enable one, either GTK or VNC
: ${VNC_LISTEN:="127.0.0.1:0"}
: ${VNC_WIDTH:="1920"}
: ${VNC_HEIGHT:="1080"}
############## Setup #########################
function cleanup {
sync
for p in "${pids[@]}"; do
log "Killing $p"
kill "$p"
log "Killed $p"
done
}
pids=()
trap "set +e; cleanup" EXIT
function die {
local status_code="$1"
shift
(>&2 echo "${@}")
exit "$status_code"
}
function log {
(>&2 echo "${@}")
}
############## Program #########################
function main {
local mount_path="$1"
shift 1
local additional_args=()
additional_args+=(-drive "file=@mountiso@,media=cdrom,id=drive-cd1,readonly=on,if=none"
-device "ahci,id=achi0"
-device "ide-cd,bus=achi0.0,drive=drive-cd1,id=cd1,bootindex=1")
additional_args+=(-fsdev "local,id=fsdev0,path=${mount_path},security_model=mapped-xattr" -device "virtio-9p-pci,fsdev=fsdev0,mount_tag=host")
mkdir -p "${mount_path}/.persist" "${mount_path}/.state"
if [ "$VNC_ENABLE" = "YES" ]; then
additional_args+=(-vnc "${VNC_LISTEN},power-control=on")
elif [ "$GTK_ENABLE" = "YES" ]; then
additional_args+=(
-device 'virtio-gpu-gl,hostmem=8G,blob=true,venus=true'
-display 'gtk,gl=on'
-vga virtio
)
else
additional_args+=(-nographic)
fi
exec qemu-system-x86_64 \
-name robot \
-accel kvm \
-cpu host \
-smp cores="$CPU_CORES" \
-m "$MEMORY" \
-rtc base=localtime \
-device virtio-rng-pci \
-drive "file=@OVMFfd@/FV/OVMF_CODE.fd,if=pflash,format=raw,readonly=on" \
-nic 'user,hostfwd=tcp::60022-:22' \
"${additional_args[@]}"
}
main "${@}"

View File

@@ -149,10 +149,11 @@
// { // {
wip = nixpkgs.legacyPackages."${system}".symlinkJoin { wip = nixpkgs.legacyPackages."${system}".symlinkJoin {
name = "wip"; name = "wip";
paths = [ paths = (
self.nixosConfigurations."controller0".config.system.build.toplevel builtins.map (name: self.nixosConfigurations."${name}".config.system.build.toplevel) (
self.nixosConfigurations."worker0".config.system.build.toplevel builtins.attrNames self.nixosConfigurations
]; )
);
}; };
} }
) )