mirror of
https://forge.darkest.space/mara/nixos-configs.git
synced 2026-11-19 11:13:59 +01:00
add agent-lab sandbox VM on muede-pc2
This commit is contained in:
parent
bb4bef7aef
commit
873622dc8a
2 changed files with 324 additions and 0 deletions
39
nixosConfigurations/agent-lab/default.nix
Normal file
39
nixosConfigurations/agent-lab/default.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
imports = [ ./hardware.nix ];
|
||||
|
||||
config = {
|
||||
# A deliberately disposable box: hyperhive agents ssh in as root and apply
|
||||
# whatever config they are testing, up to and including breaking it. The
|
||||
# host (see ../muede-pc2/agent-lab-vm.nix) only ever seeds the disk and
|
||||
# runs qemu — it never declares this system's config, so the guest is free
|
||||
# to `nixos-rebuild switch` itself out from under the seed.
|
||||
|
||||
# Agents log in by certificate, not by key. sshd accepts one the swarm's
|
||||
# SSH CA signed, and the single principal on it names the agent, so the
|
||||
# list below is what admits atlas and maia and nobody else. Dropping a name
|
||||
# ends that agent's logins at its next attempt; a signed certificate
|
||||
# expires within three hours either way.
|
||||
#
|
||||
# Spelled out rather than imported from hyperhive.nixosModules.agent-ssh-target
|
||||
# on purpose: this VM should not take the hyperhive flake as an input.
|
||||
# Re-read the CA key from the swarm's store after the CA is regenerated:
|
||||
# bao read -field=public_key ssh-agents/config/ca
|
||||
environment.etc."ssh/hyperhive-agent-ssh-ca.pub".text =
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILHGXr3Voq/SVorEoBY5cDMqTumQyHMweNQvWcSvTXuN\n";
|
||||
services.openssh.settings.TrustedUserCAKeys = "/etc/ssh/hyperhive-agent-ssh-ca.pub";
|
||||
users.users.root.openssh.authorizedPrincipals = [
|
||||
"atlas"
|
||||
"maia"
|
||||
];
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO1CRn4yYTL4XUdCebE8Z4ZeuMujBjorTdWifg911EOv pc2 home roaming"
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPDNpLDmctyqGpow/ElQvdhY4BLBPS/sigDJ1QEcC7wC lpt2-roaming"
|
||||
# muede-pc2's build key, reused as the host's provisioning identity: it is
|
||||
# how /etc/nix/netrc reaches the guest after boot without the credential
|
||||
# ever passing through the nix store. Private half stays on the host in
|
||||
# /etc/nix/distributed-build-key.
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHmnyhP6L+kGHV15cb/d31AQr50wSEaQhkUBwy2+OEKk muede-pc2-nix-builds"
|
||||
];
|
||||
};
|
||||
}
|
||||
46
nixosConfigurations/agent-lab/hardware.nix
Normal file
46
nixosConfigurations/agent-lab/hardware.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
||||
|
||||
config = {
|
||||
# Legacy BIOS boot via GRUB on the virtio disk, matching the `qemu` image
|
||||
# variant (`image.efiSupport = false`). The repo-wide systemd-boot default
|
||||
# would need an ESP plus EFI firmware and a writable varstore in the
|
||||
# runner, and a guest that reinstalls its own bootloader on every
|
||||
# `nixos-rebuild switch` is one less thing for an agent to brick. Drop that
|
||||
# module wholesale -- it also owns boot.loader.timeout and the EFI vars.
|
||||
my.systemdBoot.enable = lib.mkForce false;
|
||||
|
||||
boot = {
|
||||
loader = {
|
||||
grub = {
|
||||
enable = true;
|
||||
devices = [ "/dev/vda" ];
|
||||
};
|
||||
timeout = 1;
|
||||
};
|
||||
|
||||
# The runner resizes the seeded image before first boot (the image itself
|
||||
# is sized to its closure), so / has to grow into the rest of the disk.
|
||||
growPartition = true;
|
||||
|
||||
kernelParams = [ "console=ttyS0" ];
|
||||
tmp.cleanOnBoot = true;
|
||||
};
|
||||
|
||||
# Labels, not UUIDs: every reseed makes a brand new filesystem, and the
|
||||
# point of this machine is being thrown away and remade.
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
autoResize = true;
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
# qemu user-mode networking hands out a lease on the single virtio NIC.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue