{ description = "A very basic flake"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; # nixvirt = { # url = "https://flakehub.com/f/AshleyYakeley/NixVirt/*.tar.gz"; # inputs.nixpkgs.follows = "nixpkgs"; # }; nixvirt.url = "github:Nomkid/NixVirt"; zig2nix.url = "github:Cloudef/zig2nix"; # symlink.url = "github:schuelermine/nix-symlink"; # zig-libvirt.url = "github:Nomkid/zig-libvirt"; }; outputs = { self, nixpkgs, flake-utils, nixvirt, zig2nix }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; oslib = import ./os/lib.nix { inherit pkgs system nixvirt; }; inherit (oslib) osdb; zig-env = zig2nix.outputs.zig-env.${system} { zig = zig2nix.outputs.packages.${system}.zig.master.bin; }; # hello-vm = oslib.mkVM { # name = "hello"; # uuid = "c0c49ae7-6fe4-4c39-a8ae-c80c6b689344"; # arch = "x86_64"; # isos.beforeInstall = [ # { index = 1; file = "${osdb.windows."6.1.7601".professional.x86_64.installer}/out.iso"; } # { index = 2; file = "${osdb.windows."6.1.7601".professional.x86_64.unattend}/out.iso"; } # ]; # }; in { mkFlake = config: let vm = oslib.mkVM { inherit (config) name uuid; beforeInstall = [ { index = 1; file = "${osdb.${config.os.name}.${config.os.version}.${config.os.edition}.${config.os.arch}.installer}/out.iso"; } { index = 2; file = "${osdb.${config.os.name}.${config.os.version}.${config.os.edition}.${config.os.arch}.unattend}/out.iso"; } ]; }; in { packages.volume = vm.volume; packages.beforeInstall = vm.beforeInstallDrv; packages.afterInstall = vm.afterInstallDrv; packages.beforeBoot = vm.beforeBootDrv; packages.afterBoot = vm.afterBootDrv; }; apps = { # hello-start-vm = flake-utils.lib.mkApp { # drv = hello-vm.start-vm; # exePath = ""; # }; default = zig-env.app-no-root [] "zig build run -- \"$@\""; }; devShells.default = zig-env.mkShell { nativeBuildInputs = [ pkgs.libvirt.outPath ]; }; # For debugging. inherit oslib; } ); }