oslib/flake.nix

59 lines
2 KiB
Nix
Raw Normal View History

2024-06-24 12:54:49 -06:00
{
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";
2024-06-26 12:12:29 -06:00
zig-libvirt.url = "github:Nomkid/zig-libvirt";
2024-06-24 12:54:49 -06:00
};
2024-06-26 12:12:29 -06:00
outputs = { self, nixpkgs, flake-utils, nixvirt, zig2nix, zig-libvirt }:
2024-06-24 12:54:49 -06:00
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
oslib = import ./os/lib.nix { inherit pkgs system nixvirt; };
2024-06-24 14:05:37 -06:00
inherit (oslib) osdb;
2024-06-24 12:54:49 -06:00
zig-env = zig2nix.outputs.zig-env.${system} { zig = zig2nix.outputs.packages.${system}.zig.master.bin; };
in {
2024-06-24 14:08:21 -06:00
mkFlake = config:
flake-utils.lib.eachDefaultSystem(system:
let
vm = oslib.mkVM {
inherit (config) name uuid;
2024-06-24 14:09:52 -06:00
inherit (config.os) arch;
2024-06-24 14:11:39 -06:00
isos.beforeInstall = [
2024-06-24 14:08:21 -06:00
{ 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;
});
2024-06-24 14:05:37 -06:00
2024-06-24 12:54:49 -06:00
apps = {
default = zig-env.app-no-root [] "zig build run -- \"$@\"";
};
2024-06-26 12:12:29 -06:00
packages.zig-libvirt = zig-libvirt.packages.${system}.default;
2024-06-24 12:54:49 -06:00
devShells.default = zig-env.mkShell {
nativeBuildInputs = [ pkgs.libvirt.outPath ];
};
# For debugging.
inherit oslib;
}
);
}