fixing vm issues
This commit is contained in:
1 parent
49c6d6e6cc
commit
0e76632d2e
9 files changed
+138
-10
No files matched your search
@@ -4,3 +4,4 @@ watch_file flake.lock
|
|||||||
|
|
||||||
# devenv needs impure eval (git metadata, DEVENV_ROOT, git-hooks install).
|
# devenv needs impure eval (git metadata, DEVENV_ROOT, git-hooks install).
|
||||||
use flake . --no-pure-eval
|
use flake . --no-pure-eval
|
||||||
|
pre-commit install -f --hook-type pre-commit
|
||||||
+3
-3
@@ -29,7 +29,7 @@ Only after the user approves the plan may you proceed with edits.
|
|||||||
**DO NOT RUN ANY OF THESE COMMANDS AT ANY TIME, FOR ANY REASON:**
|
**DO NOT RUN ANY OF THESE COMMANDS AT ANY TIME, FOR ANY REASON:**
|
||||||
|
|
||||||
```
|
```
|
||||||
nix build
|
nix build # unless it's to test the vm via 'bin/runvmtest'
|
||||||
nix flake check
|
nix flake check
|
||||||
hermenix setup # unless the user is actively running it themselves with you watching
|
hermenix setup # unless the user is actively running it themselves with you watching
|
||||||
hermenix migrate # same — it writes into a live guest
|
hermenix migrate # same — it writes into a live guest
|
||||||
@@ -95,9 +95,9 @@ These are always safe to perform without asking:
|
|||||||
|
|
||||||
- Reading any file in this repo
|
- Reading any file in this repo
|
||||||
- Editing `modules/host.nix` to add/adjust options (gated behind `mkIf
|
- Editing `modules/host.nix` to add/adjust options (gated behind `mkIf
|
||||||
cfg.enable`, following the existing style)
|
cfg.enable`, following the existing style)
|
||||||
- Editing `nu/hermenix.nu` — check any change by parsing it (`nu
|
- Editing `nu/hermenix.nu` — check any change by parsing it (`nu
|
||||||
nu/hermenix.nu --help` and `nu nu/hermenix.nu <subcommand> --help` parse
|
nu/hermenix.nu --help` and `nu nu/hermenix.nu <subcommand> --help` parse
|
||||||
the whole file without running any subcommand body) before handing it back
|
the whole file without running any subcommand body) before handing it back
|
||||||
- Editing `guest/hermes/home` / `guest/hermes/workspace` template seed content
|
- Editing `guest/hermes/home` / `guest/hermes/workspace` template seed content
|
||||||
(as long as it stays free of real secrets — see above)
|
(as long as it stays free of real secrets — see above)
|
||||||
|
|||||||
@@ -869,7 +869,8 @@ module set `hermes-guest-image` is built from — in an ephemeral, throwaway
|
|||||||
NixOS test VM. No real disk under `/var/lib/hermes-vm/**` is ever touched:
|
NixOS test VM. No real disk under `/var/lib/hermes-vm/**` is ever touched:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nix build .#checks.x86_64-linux.guest-vm --impure -L
|
runvmtest # plain pass/fail (nix build .#checks.x86_64-linux.guest-vm --impure -L)
|
||||||
|
runvmtest-debug # build the interactive driver and drop into it (ptpython REPL)
|
||||||
```
|
```
|
||||||
|
|
||||||
Checks first-boot seeding (`~/.hermes`, `~/workspace`, the `/etc/nixos`
|
Checks first-boot seeding (`~/.hermes`, `~/workspace`, the `/etc/nixos`
|
||||||
@@ -878,3 +879,7 @@ the `.seeded` marker), the `hermes` user/sudo setup, and SSH. It
|
|||||||
deliberately does not cover the real `hermes-install` script (no internet
|
deliberately does not cover the real `hermes-install` script (no internet
|
||||||
route inside the test VM) or `modules/host.nix`'s own `hermes-vm` QEMU
|
route inside the test VM) or `modules/host.nix`'s own `hermes-vm` QEMU
|
||||||
service — both stay manual, operator-run checks.
|
service — both stay manual, operator-run checks.
|
||||||
|
|
||||||
|
`runvmtest-debug` gives you `start_all()`, `machine.wait_for_unit(...)`, and
|
||||||
|
`machine.shell_interact()` (a live shell inside the guest) to step through a
|
||||||
|
failure by hand instead of just getting pass/fail.
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env nu
|
||||||
|
#
|
||||||
|
# runvmtest — build and run the guest-config VM test (guest/vm-test.nix).
|
||||||
|
#
|
||||||
|
# Plain pass/fail: the build fails if any testScript assertion fails. For
|
||||||
|
# stepping through it interactively instead, use runvmtest-debug.
|
||||||
|
#
|
||||||
|
# --impure is required because guest/common.nix reads
|
||||||
|
# /etc/hermenix/local.nix if present, same as the real hermes-guest-image
|
||||||
|
# build — a pre-existing property of common.nix, not something this test
|
||||||
|
# introduces.
|
||||||
|
#
|
||||||
|
# Not run for you automatically: this needs a real build, which agents in
|
||||||
|
# this repo don't run (see GUIDELINES.md). You (or CI) run this by hand.
|
||||||
|
|
||||||
|
def main [] {
|
||||||
|
^nix build ".#checks.x86_64-linux.guest-vm" --impure -L
|
||||||
|
}
|
||||||
Executable
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env nu
|
||||||
|
#
|
||||||
|
# runvmtest-debug — build the guest-config VM test's interactive driver and
|
||||||
|
# drop into it, instead of just running it for pass/fail (see runvmtest).
|
||||||
|
#
|
||||||
|
# Opens a Python (ptpython) REPL with the test's node defined but not yet
|
||||||
|
# started. Useful from there:
|
||||||
|
# start_all()
|
||||||
|
# machine.wait_for_unit("multi-user.target")
|
||||||
|
# machine.shell_interact() # live shell inside the guest, over the console
|
||||||
|
# machine.succeed("...") # run any assertion from guest/vm-test.nix by hand
|
||||||
|
#
|
||||||
|
# Same --impure requirement as runvmtest, same reason (guest/common.nix
|
||||||
|
# reads /etc/hermenix/local.nix if present). Not run for you automatically
|
||||||
|
# — needs a real build, which agents in this repo don't run.
|
||||||
|
|
||||||
|
def main [] {
|
||||||
|
^nix build ".#checks.x86_64-linux.guest-vm.driverInteractive" --impure -L
|
||||||
|
^./result/bin/nixos-test-driver
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"devenv": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "src/modules",
|
||||||
|
"lastModified": 1789480904,
|
||||||
|
"narHash": "sha256-anHWHTkxI7423/eUroN9Rc4+H8VIGyIUWq/hV1egBDQ=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv",
|
||||||
|
"rev": "0fd5e6d3a9b2ae6f10205a3e95e0ca58d526c5a6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "src/modules",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-src": "nixpkgs-src"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1789506231,
|
||||||
|
"narHash": "sha256-vNkJbtmqyBfFhn/HnzQo4ROuoyYWuy/allqTfJb4kMY=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv-nixpkgs",
|
||||||
|
"rev": "c2f38fe7f9e04d9aadd354d380f2bd40531d9737",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"ref": "rolling",
|
||||||
|
"repo": "devenv-nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1789370336,
|
||||||
|
"narHash": "sha256-6RSEDHIWQtesQKWSu5qRai8L2h4KgCgMEfJHstW99G4=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "c7def046b9a883d46974757852106483d741586f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"devenv": "devenv",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ in
|
|||||||
nixfmt
|
nixfmt
|
||||||
deadnix
|
deadnix
|
||||||
statix
|
statix
|
||||||
|
pre-commit
|
||||||
];
|
];
|
||||||
|
|
||||||
env.NU_LIB_DIRS = "${inputs.nutest}";
|
env.NU_LIB_DIRS = "${inputs.nutest}";
|
||||||
|
|||||||
+9
-2
@@ -137,19 +137,26 @@ in
|
|||||||
cp -rTn ${./hermes/workspace} ${stateDir}/workspace
|
cp -rTn ${./hermes/workspace} ${stateDir}/workspace
|
||||||
|
|
||||||
chmod -R u+w ${stateDir}/nixos ${stateDir}/.hermes ${stateDir}/workspace
|
chmod -R u+w ${stateDir}/nixos ${stateDir}/.hermes ${stateDir}/workspace
|
||||||
chown -R hermes:hermes ${stateDir}/nixos ${stateDir}/.hermes ${stateDir}/workspace
|
|
||||||
|
|
||||||
# Git history here is the agent's cheapest undo, and it stops
|
# Git history here is the agent's cheapest undo, and it stops
|
||||||
# nixos-rebuild complaining about an untracked flake.
|
# nixos-rebuild complaining about an untracked flake.
|
||||||
|
#
|
||||||
|
# Must run before the chown below, while ${stateDir}/nixos is still
|
||||||
|
# root-owned: activation runs as root, and git refuses to operate on
|
||||||
|
# a repository whose working tree is owned by a different user
|
||||||
|
# ("detected dubious ownership") - it would otherwise fail here on
|
||||||
|
# every boot, silently (activation script failures are non-fatal),
|
||||||
|
# and the seed would never actually get committed.
|
||||||
if [ ! -d ${stateDir}/nixos/.git ]; then
|
if [ ! -d ${stateDir}/nixos/.git ]; then
|
||||||
${pkgs.git}/bin/git -C ${stateDir}/nixos init -q -b main
|
${pkgs.git}/bin/git -C ${stateDir}/nixos init -q -b main
|
||||||
${pkgs.git}/bin/git -C ${stateDir}/nixos add -A
|
${pkgs.git}/bin/git -C ${stateDir}/nixos add -A
|
||||||
${pkgs.git}/bin/git -C ${stateDir}/nixos \
|
${pkgs.git}/bin/git -C ${stateDir}/nixos \
|
||||||
-c user.name=seed -c user.email=seed@localhost \
|
-c user.name=seed -c user.email=seed@localhost \
|
||||||
commit -q -m "seed configuration from bootstrap image"
|
commit -q -m "seed configuration from bootstrap image"
|
||||||
chown -R hermes:hermes ${stateDir}/nixos/.git
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
chown -R hermes:hermes ${stateDir}/nixos ${stateDir}/.hermes ${stateDir}/workspace
|
||||||
|
|
||||||
touch ${stateDir}/.seeded
|
touch ${stateDir}/.seeded
|
||||||
chown hermes:hermes ${stateDir}/.seeded
|
chown hermes:hermes ${stateDir}/.seeded
|
||||||
fi
|
fi
|
||||||
|
|||||||
+15
-4
@@ -49,6 +49,12 @@ pkgs.testers.runNixOSTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
|
# allow_reboot=True: without it, the VM starts with qemu's -no-reboot,
|
||||||
|
# so the guest-initiated machine.reboot() below would just kill the VM
|
||||||
|
# instead of restarting it, and the backdoor shell would never
|
||||||
|
# reconnect. Must happen before anything else touches `machine`, which
|
||||||
|
# would otherwise auto-start it with the (False) default first.
|
||||||
|
machine.start(allow_reboot=True)
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
# seedHermesState (guest/common.nix) ran on first boot.
|
# seedHermesState (guest/common.nix) ran on first boot.
|
||||||
@@ -76,9 +82,14 @@ pkgs.testers.runNixOSTest {
|
|||||||
machine.wait_for_unit("sshd.service")
|
machine.wait_for_unit("sshd.service")
|
||||||
machine.wait_for_open_port(22)
|
machine.wait_for_open_port(22)
|
||||||
|
|
||||||
# nix.custom.conf reflects the no-host-cache default (no local.nix in
|
# NOTE: not checking /etc/nix/nix.custom.conf's content here. `nix eval`
|
||||||
# this hermetic build).
|
# on environment.etc."nix/nix.custom.conf".text confirms guest/common.nix
|
||||||
machine.succeed("grep -q cache.flakehub.com /etc/nix/nix.custom.conf")
|
# itself renders the expected (no-host-cache) content, but the actual
|
||||||
machine.fail("grep -q 'http://10.77.0.1:5000' /etc/nix/nix.custom.conf")
|
# booted guest's copy of that file instead holds the NixOS test
|
||||||
|
# framework's own injected nix.settings (substituters = cache.nixos.org,
|
||||||
|
# trusted-users = root, system-features = nixos-test ...) — needed so
|
||||||
|
# nested Nix operations inside the test VM work at all. That's an
|
||||||
|
# artifact of running under nixosTest, not something guest/common.nix or
|
||||||
|
# this test controls, so it's not a reliable thing to assert on here.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user