# Guest-config tier VM test: boots guest/common.nix (the same module set # used to build hermes-guest-image, see flake.nix) in an ephemeral, # throwaway NixOS test VM, and checks seeding/services. This never touches # a real disk under /var/lib/hermes-vm/** and never runs `hermenix setup`. # # guest/hardware.nix (the real disk-label file) is intentionally not # imported here, same as hermes-guest-image's own build — nixos-generators # and, here, the NixOS test framework both supply their own bootloader and # root filesystem instead. # # Build with (never run by an agent, only by the operator/CI): # nix build .#checks.x86_64-linux.guest-vm --impure -L # # --impure is required because guest/common.nix reads /etc/hermenix/local.nix # if present (see its own comment) — a pre-existing property of common.nix, # not something introduced by this test. { pkgs, determinate }: pkgs.testers.runNixOSTest { name = "hermenix-guest-config"; nodes.machine = { lib, ... }: { imports = [ determinate.nixosModules.default ../guest/common.nix ]; # A real, separate, auto-formatted virtual disk for the state dir — # not tmpfs. tmpfs would not survive the in-test reboot below, which # would make the idempotency check below pass for the wrong reason # (nothing to re-seed over, rather than correctly skipping re-seeding). virtualisation.emptyDiskImages = [ 1024 ]; fileSystems."/var/lib/hermes" = lib.mkForce { device = "/dev/vdb"; fsType = "ext4"; autoFormat = true; neededForBoot = true; }; # nixosTest VMs have no route to the internet by design, so the real # hermes-install body (a third-party curl | bash installer) can't run # hermetically here. Stubbed to just flag itself done; the real # installer flow stays an operator-run manual smoke test. systemd.services.hermes-install.script = lib.mkForce '' touch /var/lib/hermes/.hermes-installed ''; }; testScript = '' machine.wait_for_unit("multi-user.target") # seedHermesState (guest/common.nix) ran on first boot. machine.succeed("test -e /var/lib/hermes/.seeded") machine.succeed("test -f /var/lib/hermes/.hermes/SOUL.md") machine.succeed("test -d /var/lib/hermes/workspace") machine.succeed("test -d /var/lib/hermes/nixos/.git") machine.succeed("readlink /etc/nixos | grep -q '^/var/lib/hermes/nixos$'") # The single most important invariant in guest/common.nix (per its own # comments): seeding must never re-run over an already-seeded state # disk, or every rebuild would quietly wipe the agent's own edits to # SOUL.md, memories, etc. machine.succeed("echo IDEMPOTENCY_MARKER >> /var/lib/hermes/.hermes/SOUL.md") machine.reboot() machine.wait_for_unit("multi-user.target") machine.succeed("grep -q IDEMPOTENCY_MARKER /var/lib/hermes/.hermes/SOUL.md") # The agent's account. machine.succeed("id hermes") machine.succeed("groups hermes | grep -q wheel") machine.succeed("su - hermes -c 'sudo -n true'") # SSH is up. machine.wait_for_unit("sshd.service") machine.wait_for_open_port(22) # nix.custom.conf reflects the no-host-cache default (no local.nix in # this hermetic build). machine.succeed("grep -q cache.flakehub.com /etc/nix/nix.custom.conf") machine.fail("grep -q 'http://10.77.0.1:5000' /etc/nix/nix.custom.conf") ''; }