{ description = "hermenix — Hermes Agent in a self-managing NixOS VM, two-disk btrfs-backed, under hardened QEMU"; inputs = { nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; determinate.url = "https://flakehub.com/f/DeterminateSystems/determinate/3"; nixos-generators = { url = "github:nix-community/nixos-generators"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, determinate, nixos-generators, ... }@inputs: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; # nu/lib/common.nu holds helpers shared by every host-side tool below # (say/note/ok/warn/die/step/ask/confirm/confirm-word/shquote, # vsock-ssh-args, run-argv). It's never `use`d at runtime - once a # script is wrapped into a single file in the Nix store, a relative # `use` isn't reliably resolvable - so it's concatenated in here # instead, in front of each tool's own script. nuScript = path: (builtins.readFile ./nu/lib/common.nu) + "\n" + (builtins.readFile path); in { nixosModules.default = ./modules/host.nix; packages.${system} = { # One-time bootstrap image. See the README: building this needs two # extra substituter flags so you aren't compiling Determinate Nix # yourself. hermes-guest-image = nixos-generators.nixosGenerate { inherit system; format = "raw-efi"; modules = [ determinate.nixosModules.default ./guest/common.nix ]; }; # The host-side CLI: `hermenix setup` (guided disk/cache/image setup) # and `hermenix migrate ` (carry over an existing flat # HERMES_HOME). A Nu script, wrapped so its external dependencies are # always on PATH regardless of what the host happens to have # installed. hermenix = pkgs.writers.writeNuBin "hermenix" { makeWrapperArgs = [ "--prefix" "PATH" ":" (pkgs.lib.makeBinPath (with pkgs; [ openssh socat gnutar gnused btrfs-progs e2fsprogs coreutils nix ])) ]; } (nuScript ./nu/hermenix.nu); # Host-side control of the VM itself (start/stop/console/snapshots/ # backups) - see nu/hermes-vm.nu. Defaults match # services.hermenix's own option defaults; modules/host.nix wraps # this same script with the per-host values baked in via env vars # instead (see its own writeNuBin calls). hermes-vm = pkgs.writers.writeNuBin "hermes-vm" { makeWrapperArgs = [ "--prefix" "PATH" ":" (pkgs.lib.makeBinPath (with pkgs; [ openssh socat coreutils gnutar btrfs-progs util-linux restic ])) ]; } (nuScript ./nu/hermes-vm.nu); # Host-side control of Hermes itself, inside the guest (identity, # config, secrets, gateway service, passthrough to its own `hermes` # CLI) - see nu/hermes-ctl.nu. Same per-host-defaults/module-override # relationship as hermes-vm above. hermes-ctl = pkgs.writers.writeNuBin "hermes-ctl" { makeWrapperArgs = [ "--prefix" "PATH" ":" (pkgs.lib.makeBinPath (with pkgs; [ openssh socat coreutils gnutar vim ])) ]; } (nuScript ./nu/hermes-ctl.nu); default = self.packages.${system}.hermenix; }; }; }