{ 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}; 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}-${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; }; }; }