Commit Graph
47 Commits
Author SHA1 Message Date
ari ed558a196f ensuring only relevant access is provided 2026-10-26 12:26:19 -04:00
ari 5b2621acbc networking tests 2026-10-11 00:59:32 -04:00
ari f1622fae84 splitting host.nix 2026-10-10 22:56:24 -04:00
ari 053b9c4c95 more docs 2026-10-10 22:06:12 -04:00
ari 30427e3975 doc clean 2026-10-09 14:35:12 -04:00
ari c2a7f94821 logo 2026-10-09 11:20:32 -04:00
ari 32edfbd111 added flags for virt devices 2026-09-29 11:33:33 -04:00
ari d5afd6510f safer bridge mode 2026-09-23 19:29:28 -04:00
ari b5d59c34ac readme ticks 2026-09-23 14:29:25 -04:00
ari 42e903909c fixing test failures 2026-09-23 13:24:07 -04:00
ari c8ff8b1f25 simpler derivation 2026-09-18 12:33:33 -04:00
ari a538f70bf7 another attempt at fixing it 2026-09-17 17:27:56 -04:00
ari 4313e043bc fixing nats 2026-09-17 17:00:35 -04:00
ari 708a02a6d5 fixing tests 2026-09-17 16:53:00 -04:00
ari ab8260a5d0 better test + migration 2026-09-17 16:26:15 -04:00
ari 27b713affa fixing migration bugs + tests 2026-09-17 15:46:19 -04:00
ari 2d35fd973c detailed versioning + no dest 2026-09-17 15:29:06 -04:00
ari 64ab08d891 carry connections 2026-09-17 15:23:16 -04:00
ari 0e76632d2e fixing vm issues 2026-09-17 15:16:29 -04:00
ari 49c6d6e6cc testing 2026-09-17 14:38:27 -04:00
ari d47c401013 hooks + devenv 2026-09-17 14:14:14 -04:00
ari e07ae98c0b nufmt after generation 2026-09-17 13:21:00 -04:00
ari b1c6a52503 hooks + devenv 2026-09-17 13:18:19 -04:00
ari 45d2d9e489 completions 2026-09-17 12:35:04 -04:00
ari 21e87b6bfa new single file with fixes 2026-09-17 12:15:53 -04:00
ari f5f6a98152 all nuing with versions 2026-09-16 22:15:07 -04:00
ari 1e1da2f7a1 all nuing 2026-09-16 22:09:42 -04:00
ari e99744f628 guest: rm -rf /etc/nixos before symlinking it to the state disk
/etc/nixos is a real directory by default on NixOS. ln -sfn only replaces
an existing LINKNAME in place when it's already a symlink; against a plain
directory it instead creates the link *inside* it, leaving /etc/nixos
itself untouched. Confirmed live: /etc/nixos/nixos -> /var/lib/hermes/nixos
existed while /etc/nixos itself stayed a stray empty directory, so
`nix flake lock /etc/nixos` couldn't find a flake.nix. rm -rf first makes
this idempotent regardless of what currently occupies the path.
2026-09-16 12:00:13 -04:00
ari 55467ba8bf guest: add ~/.local/bin to PATH via environment.localBinInPath
hermes has createHome = false (home is the seeded state disk, not NixOS's
usual skeleton), so it never gets a ~/.bashrc for the installer to patch -
confirmed live ("hermes: command not found", no .bashrc to source). The
installer puts its launcher in ~/.local/bin and says as much. This option
wires PATH through /etc/set-environment (PAM, every login) instead, same
as hl-fwdesk.nix already does on the physical host.
2026-09-16 11:48:56 -04:00
ari e5f150b17e fixed issue with networking 2026-09-16 11:40:45 -04:00
ari f1456b66e5 guest: give hermes-install a broader PATH (fixes sh: command not found)
hermesInstallDeps had no package providing a bare `sh` - the upstream
installer's uv-install step invokes it via PATH lookup, not /bin/sh, and
NixOS systemd units only get a `path`'s explicit packages. bash's own bin/
ships an sh -> bash symlink, confirmed against the exact store path from
the failing unit's log. Also adds a broader coreutils-adjacent baseline
(tar, gzip, which, grep, sed, awk, find) so the next installer that shells
out to a common tool by bare name doesn't cost another rebuild cycle.
2026-09-16 11:09:28 -04:00
ariandClaude Sonnet 5 04d1889101 Fix hermes-install: give the service an actual PATH
Confirmed live: "curl: command not found" inside hermes-install,
despite curl being in environment.systemPackages. Real NixOS gotcha -
systemPackages populates the interactive PATH (/run/current-system/sw/bin
via /etc/profile), but systemd services get their own minimal PATH
unless the unit is explicitly given one via `path = [...]`. The
installer also shells out to git/node/python/gcc internally, so it's
not just curl that was unreachable.

Factored the package list (previously only in environment.systemPackages)
into a shared `hermesInstallDeps` binding, used for both
environment.systemPackages and hermes-install's `path`, so there's one
list to keep in sync rather than two.

set -euo pipefail (from the last fix) meant this failed loudly and
retried instead of silently self-marking done - working as intended,
just surfacing the next real bug in the chain.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-16 10:56:48 -04:00
ariandClaude Sonnet 5 70c8c275c1 --clean: also drop the stale known_hosts entry for the guest
A fresh state disk means openssh generates a brand new host key on
next boot, but the old ~/.ssh/known_hosts entry for "hermes" (from
vsock connections) sticks around - the next hermes-vm ssh/hermes-ctl/
migrate connection would otherwise fail on a host-key mismatch, since
StrictHostKeyChecking=accept-new only accepts genuinely new hosts, not
a changed key for an already-known one.

ssh-keygen -R hermes runs unprivileged (the invoking user's own
known_hosts, not a root-owned path) and is a safe no-op if there's
nothing to remove - verified directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-16 10:53:34 -04:00
ariandClaude Sonnet 5 6d7ff4eace Fix: hermenix remote host setup --clean failed to parse at all
nu's own CLI dispatch treats any bare --flag-shaped token as an
attempt to match a flag on the CURRENT command, even when it's meant
for a rest parameter, and even with a `--` separator (confirmed
neither `...args: string` nor `-- ` sidesteps it - both still error
before ever reaching the function body). This broke `hermenix remote
<host> setup --clean` outright, both locally and thus for anyone
running it - confirmed live on hl-fwdesk right after landing --clean.

Changed `main remote`'s second parameter from a rest param to a single
`cmd: string` - the caller now quotes the subcommand and its flags as
one string ("setup --clean", "migrate /var/lib/hermes"). Since it's a
single value bound to a plain string parameter, nu never inspects its
contents for flags. Inside main remote, cmd is split back into words
and each one re-quoted for the actual remote invocation, so the
semantics on the wire are unchanged - just the calling convention.

Verified: the exact previously-failing invocation now parses and
constructs the correct `'setup' '--clean'` remote command (checked
directly, not just parse-checked).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-16 10:47:34 -04:00
ariandClaude Sonnet 5 3c491b1624 Add hermenix setup --clean for a fully fresh start
Encodes the "start over" runbook from tonight's incident as a flag:
stops hermes-vm.service, deletes system.raw/state.raw/OVMF_VARS.fd,
then continues through the normal setup flow. Leaves the btrfs
subvolumes and any snapshots untouched - only the files inside them.
Gated behind a confirm-word ("clean") since it's destructive.

Verified in a sandbox: confirms it stops the VM and removes exactly
the three targeted files (nothing else), that declining the
confirm-word aborts without touching anything, and that it correctly
falls through into the normal disk-creation flow afterward.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-16 10:42:41 -04:00
ariandClaude Sonnet 5 ff752cb803 Fix hermes-install: add set -euo pipefail so failures don't self-mark done
Without it, a failed curl|bash (network not up yet on a very early
boot, or any other transient failure) fell through to the final
`touch .hermes-installed` line regardless - permanently marking the
install "done" via the ConditionPathExists gate even though it never
completed. Confirmed live on hl-fwdesk: journalctl --list-boots showed
a 2-second first boot, and the marker's birth time matched exactly the
end of that boot - the real boot then skipped the service entirely
because the marker already existed, leaving `hermes` never installed.

pipefail specifically matters here: plain -e alone only checks the
last command in `curl | bash`, so a failing curl with a trivially
successful (empty-input) bash would not have been caught without it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 22:40:04 -04:00
ariandClaude Sonnet 5 5ea64e88d5 Fix two disk-setup bugs: byte/gigabyte size mix-up, wrong ownership
1. truncate -s treats a bare number as bytes, not gigabytes - typing
   "50" at the size prompt (instead of "50G") silently made a 50-byte
   file, which then failed mkfs.ext4 with "Device size reported to be
   zero." Added normalize-size: a bare integer answer now gets a "G"
   suffix appended (matching what the prompts' own defaults imply),
   anything with an existing suffix passes through unchanged.

2. Every disk-creation step runs through `priv` (sudo/root), so
   subvolumes and disk images always ended up root-owned - but
   hermes-vm.service runs as the unprivileged hermes-vm account, which
   only had read access via the "other" bits. QEMU failed to open
   system.raw for read-write. Added explicit `chown hermes-vm:hermes-vm`
   after every creation point (both make-subvol branches, and after
   each truncate/mkfs) - also self-heals already-existing
   wrongly-owned disks on a re-run, not just fresh ones.

Both confirmed live on hl-fwdesk during tonight's incident. Verified
with a unit test of normalize-size and a full sandboxed interactive
dry run of `setup` (fake sudo/btrfs/truncate/chown/mkfs.ext4) showing
the correct truncate -> chown ordering for both disks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 22:33:09 -04:00
ariandClaude Sonnet 5 1239ea0148 Bake in build toolchain + auto-run the Hermes installer on first boot
guest/common.nix was missing gcc/make/pkg-config/python3/xz, so the
installer's node-pty compile step failed with "No C++ compiler found" -
confirmed live during the hl-fwdesk incident.

Also added systemd.services.hermes-install: runs the installer
unattended (--non-interactive --skip-setup, confirmed supported via
upstream's install.sh --help) as part of first boot, gated on its own
.hermes-installed marker (same pattern as seedHermesState's .seeded). A
real service rather than an activation script since it can take a
while (compiling native modules) and shouldn't block boot or a
nixos-rebuild. `hermes setup`/`hermes gateway install` stay manual -
upstream docs don't show a non-interactive path for those, and they
need real credentials anyway.

Updated the README and the setup/migrate CLI's printed next-steps to
match - two manual commands left instead of four.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 17:12:40 -04:00
ariandClaude Sonnet 5 67477953f1 Add --refresh to force fresh git resolution, not a cached rev
hl-fwdesk's nix resolved git+ssh://.../hermenix.git?ref=main against a
cached ref->rev mapping from an earlier fetch this session, running a
stale commit's nu/hermenix.nu (from before flake.lock existed) and
hitting the exact same "cannot write modified lock file" error again
despite both fixes already being pushed. --refresh forces Nix to check
Gitea for the current tip on every invocation instead of trusting the
cached resolution (respects tarball-ttl otherwise) - required given the
whole design point is "always run whatever's current, no manual pull."

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 15:48:31 -04:00
ariandClaude Sonnet 5 825094c4cf Commit flake.lock; keep --no-write-lock-file as a defensive fallback
Fixes "cannot write modified lock file" when running hermenix straight
from its git+ssh URL (no local checkout) - Nix had nothing committed to
resolve its own sub-inputs (nixos-generators, determinate, nixpkgs)
against, and can't write one back to a fetched, read-only copy. A
committed, current flake.lock means there's nothing left to resolve on
a normal run.

Also finished threading --no-write-lock-file through the two remaining
CLI-constructed invocations (setup's printed manual-fallback text, and
remote's constructed command) that were missed in the prior commit -
harmless once the lock is current, and keeps things working even if the
lock ever drifts stale before it's refreshed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 15:38:49 -04:00
ariandClaude Sonnet 5 41ea93a28f Eliminate the git-clone dependency entirely
hermenix setup/migrate/remote no longer need a local checkout anywhere:

- Host-specific settings (cache signing key, SSH keys) now live at
  /etc/hermenix/local.nix on the host itself, read via an absolute-path
  import in common.nix (--impure, deliberately - reading outside the
  flake's own source tree). No more guest/common.nix patching, no more
  guest/common.nix.bak, no more git-pull conflicts on a locally-edited
  tracked file (see the hermes-vm.service incident on hl-fwdesk).
- `setup` builds directly from the flake's own git+ssh URL by default
  (--flake to override), so it works from any directory on any host -
  dropped the "run this from the hermenix repository root" requirement
  entirely.
- `remote` now just runs `nix run <flake>#hermenix -- ...` on the target
  host directly - dropped the clone-if-missing/--dir/--repo machinery,
  since there's no checkout to manage anymore.

guest/local.nix.example documents the expected shape. Verified the
write-then-read-back round trip (nix-instantiate --eval --json) and the
simplified remote command construction against sandboxed stubs before
pushing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 15:10:13 -04:00
ariandClaude Sonnet 5 2078204168 Fix bootstrap image: missing virtio drivers stranded it in initrd
The bootstrap image (built from common.nix alone - nixos-generators
supplies its own partitioning/bootloader, which is why hardware.nix is
excluded from it) never got hardware.nix's qemu-guest.nix profile or
virtio initrd modules. Both disks are virtio-blk, including the one the
image itself boots from, so the initrd couldn't find its own root
device: "Timed out waiting for device /dev/disk/by-label/nixos",
dropping to emergency mode with root locked - confirmed live on
hl-fwdesk. The label itself was correct (verified via a read-only
losetup + blkid against the built image); the initrd genuinely had no
virtio_blk/virtio_pci module and no qemu-guest.nix profile at all.

Moved the qemu-guest.nix import and virtio_pci/virtio_blk/virtio_scsi
initrd modules from hardware.nix into common.nix, which both the
bootstrap build and the guest's own post-first-boot flake (via
guest/flake.nix importing both files) pull in. hardware.nix keeps only
the partition-specific fileSystems/bootloader config, which genuinely
does need to stay out of the bootstrap build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 14:49:13 -04:00
ariandClaude Sonnet 5 d961d38974 Fix hermes-vm.service crash-loop: drop mismatched multi_queue tap flag
QEMU's -netdev tap line never requests queues=N, so a persistent tap
created with `multi_queue` fails TUNSETIFF with EINVAL on every attach
attempt ("could not configure /dev/net/tun: Invalid argument"),
crash-looping the VM indefinitely. Confirmed live on hl-fwdesk via
`ip tuntap show` (tap flagged multi_queue, numqueues 0 - never
successfully attached).

vhost is already off in this design, so multiqueue bought nothing here
anyway - just drop the flag from tap creation instead of adding
matching queues= plumbing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 14:33:39 -04:00
ariandClaude Sonnet 5 c39be5e6de Fix deprecated 'str downcase' in confirm helper
str downcase/str lowercase differ across nu versions (renamed in
0.114.0); avoid depending on either by checking both cases directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 14:17:18 -04:00
ariandClaude Sonnet 5 de2649f6e0 Add hermenix remote for driving setup/migrate over SSH
hermenix remote <host> <setup|migrate> [args...] SSHes to the target
host with a pty, clones this repo there only if it isn't already
checked out (never touches an existing checkout beyond running the
command), then runs `nix run .#hermenix -- ...` in it. Lets setup/
migrate be triggered from wherever hermenix is installed, without
manually SSHing into the target host first.

Verified with a sandboxed dry run (local ssh/git/nix stubs): fresh
clone, existing-checkout skip-clone, custom --dir/--repo, and the
no-args usage guard.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 13:59:30 -04:00
ariandClaude Sonnet 5 2b33b98bae Rename project to hermenix; convert host scripts to a Nu CLI
services.hermesVm -> services.hermenix throughout. setup.sh and
migrate-docker-hermes.sh are replaced by nu/hermenix.nu (setup + migrate
subcommands), packaged as a flake output (packages.${system}.hermenix,
pkgs.writers.writeNuBin) so it's installable without cloning conventions
beyond the repo itself. Both subcommands verified end-to-end against a
sandboxed dry run (stubbed disk/cache tools, a local ssh stand-in for the
migrate path) before landing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 13:26:18 -04:00
ariandClaude Sonnet 5 12227460fd Initial hermex: Hermes Agent in a hardened, self-managing NixOS VM
Two-disk (system/state) btrfs-backed QEMU VM, nftables-isolated by default,
adapted from a design provided as loose files. Adds a hermesHome option to
the host module and migrate-docker-hermes.sh so an existing flat HERMES_HOME
(e.g. from a prior Docker deployment) can be carried over intact.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 12:20:45 -04:00