server-configuration/lib/default.nix
2025-03-04 13:45:46 +01:00

42 lines
948 B
Nix

{
self,
nixpkgs,
...
}:
nixpkgs.lib.extend (
_final: prev: let
inherit (prev) mkIf;
in {
extensions = {
createvm = {
name,
system ? nixpkgs.system,
config,
}: {microvm, ...}: {
imports = [microvm.host];
microvm.hypervisor = "cloud-hypervisor";
microvm.vms.${name} = {
pkgs = import nixpkgs {inherit system;};
microvm.shares = [
{
tag = "ro-store";
source = "/nix/store";
mountPoint = "/nix/.ro-store";
}
];
inherit config;
};
# Mount host /nix/store for drastically reduced image size and evaluation time
microvm.vms.${name}.config.shares = [
{
source = "/nix/store";
mountPoint = "/nix/.ro-store";
tag = "ro-store";
proto = "virtiofs";
}
];
};
};
}
)