oslib/flake.nix

58 lines
2 KiB
Nix

{
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";
zig-libvirt.url = "github:Nomkid/zig-libvirt";
};
outputs = { self, nixpkgs, flake-utils, nixvirt, zig2nix, zig-libvirt }:
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; };
in {
mkFlake = config:
flake-utils.lib.eachDefaultSystem(system:
let
vm = oslib.mkVM {
inherit (config) name uuid;
inherit (config.os) arch;
isos.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 = {
default = zig-env.app-no-root [] "zig build run -- \"$@\"";
};
packages.zig-libvirt = zig-libvirt.packages.${system}.default;
devShells.default = zig-env.mkShell {
nativeBuildInputs = [ pkgs.libvirt.outPath ];
};
# For debugging.
inherit oslib;
}
);
}