3 Commits

Author SHA1 Message Date
9b014c5ff0 [microvm] fix comparision
Some checks failed
Evaluate Hydra Jobs / eval-hydra-jobs (push) Has been cancelled
Evaluate Hydra Jobs / eval-hydra-jobs (pull_request) Successful in 4m9s
2024-11-21 13:06:28 +01:00
1c66b6db8c [microvm] add microvm deployment option to host
Some checks failed
Evaluate Hydra Jobs / eval-hydra-jobs (push) Has been cancelled
Evaluate Hydra Jobs / eval-hydra-jobs (pull_request) Successful in 3m23s
2024-11-21 13:00:21 +01:00
1cecd21763 [microvm] share read only nix store
All checks were successful
Evaluate Hydra Jobs / eval-hydra-jobs (pull_request) Successful in 4m48s
Evaluate Hydra Jobs / eval-hydra-jobs (push) Successful in 5m0s
this reduces build times drastically
2024-11-19 19:42:52 +01:00
2 changed files with 32 additions and 0 deletions

View File

@@ -46,6 +46,11 @@ let
{
microvm = {
hypervisor = "qemu";
shares = [ {
tag = "ro-store";
source = "/nix/store";
mountPoint = "/nix/.ro-store";
} ];
interfaces = [
{
type = "tap";

View File

@@ -13,6 +13,14 @@ in
type = types.bool;
description = lib.mdDoc "Setup bridge device for microvms.";
};
deployHosts = mkOption {
default = [];
type = types.listOf string;
description = ''
List hostnames of MicroVMs that should be automatically initializes and autostart
'';
};
};
};
@@ -48,5 +56,24 @@ in
networkConfig.Bridge = "microvm";
};
};
imports = mkIf (lib.length cfg.deployHosts != 0) [
inputs.microvm.nixosModules.host
];
microvm.autostart = cfg.deployHosts;
microvm.vms =
let
# Map the values to each hostname to then generate a Attrs using listToAttrs
mapperFunc = name: { inherit name; value = {
# Host build-time reference to where the MicroVM NixOS is defined
# under nixosConfigurations
flake = self;
# Specify from where to let `microvm -u` update later on
updateFlake = "git+https://git.dynamicdiscord.de/kalipso/infrastructure?ref=microvm";
}; };
in
mkIf (lib.length cfg.deployHosts != 0)
builtins.listToAttrs (map mapperFunc cfg.deployHosts);
};
}