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

41 lines
940 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";
}
];
};
};
}
)