{ 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"; }; devenv = { url = "github:cachix/devenv"; inputs.nixpkgs.follows = "nixpkgs"; }; git-hooks = { url = "github:cachix/git-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; }; treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; # No nixpkgs package; plain source for nu/tests. nutest = { url = "github:vyadh/nutest/v1.2.0"; flake = false; }; }; outputs = { self, nixpkgs, determinate, nixos-generators, devenv, ... }@inputs: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; nuScript = builtins.concatStringsSep "\n" ( map builtins.readFile [ ./nu/lib/common.nu ./nu/lib/guest.nu ./nu/host/setup.nu ./nu/host/migrate.nu ./nu/host/remote.nu ./nu/vm/vm.nu ./nu/ctl/ctl.nu ./nu/hermenix.nu ] ); gitRev = self.rev or self.dirtyRev or "unknown"; shortRev = if gitRev == "unknown" then "unknown" else builtins.substring 0 7 gitRev; version = "${builtins.substring 0 4 self.lastModifiedDate}." + "${builtins.substring 4 2 self.lastModifiedDate}." + "${builtins.substring 6 2 self.lastModifiedDate}." + "${builtins.substring 8 2 self.lastModifiedDate}." + "${builtins.substring 10 2 self.lastModifiedDate}-${shortRev}"; in { nixosModules.default = { lib, ... }: { imports = [ ./modules/host.nix ]; config.services.hermenix.version = lib.mkDefault version; }; packages.${system} = { hermes-guest-image = nixos-generators.nixosGenerate { inherit system; format = "raw-efi"; modules = [ determinate.nixosModules.default ./guest/common.nix ]; }; hermenix = pkgs.writers.writeNuBin "hermenix" { makeWrapperArgs = [ "--prefix" "PATH" ":" (pkgs.lib.makeBinPath ( with pkgs; [ openssh socat gnutar gnused btrfs-progs e2fsprogs util-linux restic coreutils vim nix ] )) "--set" "HERMENIX_VERSION" version ]; } nuScript; hermenix-completions = pkgs.writeTextFile { name = "hermenix-completions"; destination = "/share/nushell/vendor/autoload/hermenix.nu"; text = builtins.readFile ./nu/completions.nu; }; default = self.packages.${system}.hermenix; }; devShells.${system}.default = devenv.lib.mkShell { inherit inputs pkgs; modules = [ ./devenv.nix ]; }; checks.${system} = (import ./guest/vm-tests { inherit pkgs determinate; hermenix = self.packages.${system}.hermenix; }) // { network-modes = import ./tests/network-modes-check.nix { inherit pkgs; }; host-vm = import ./tests/host-vm-test.nix { inherit pkgs self; }; }; }; }