forked from kalipso/infrastructure
[microvm] put vm creation into function
This commit is contained in:
@@ -41,12 +41,33 @@ let
|
|||||||
];
|
];
|
||||||
defaultModules = baseModules;
|
defaultModules = baseModules;
|
||||||
|
|
||||||
defaultMicroVMModules = [
|
makeMicroVM = hostName: ipv4Addr: modules: [
|
||||||
inputs.microvm.nixosModules.microvm
|
inputs.microvm.nixosModules.microvm
|
||||||
{
|
{
|
||||||
microvm.hypervisor = "qemu";
|
microvm = {
|
||||||
|
hypervisor = "qemu";
|
||||||
|
interfaces = [
|
||||||
|
{
|
||||||
|
type = "tap";
|
||||||
|
id = "vm-${hostName}";
|
||||||
|
mac = "02:00:00:00:00:01";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.network.enable = true;
|
||||||
|
|
||||||
|
systemd.network.networks."20-lan" = {
|
||||||
|
matchConfig.Type = "ether";
|
||||||
|
networkConfig = {
|
||||||
|
Address = [ "${ipv4Addr}/24" ];
|
||||||
|
Gateway = "10.0.0.1";
|
||||||
|
DNS = ["1.1.1.1"];
|
||||||
|
DHCP = "no";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
] ++ defaultModules;
|
] ++ defaultModules ++ modules;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
louise = nixosSystem {
|
louise = nixosSystem {
|
||||||
@@ -60,33 +81,8 @@ in
|
|||||||
durruti = nixosSystem {
|
durruti = nixosSystem {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
specialArgs.inputs = inputs;
|
specialArgs.inputs = inputs;
|
||||||
modules = defaultMicroVMModules ++ [
|
modules = makeMicroVM "durruti" "10.0.0.5" [
|
||||||
./durruti/configuration.nix
|
./durruti/configuration.nix
|
||||||
|
|
||||||
{
|
|
||||||
microvm = {
|
|
||||||
interfaces = [
|
|
||||||
{
|
|
||||||
type = "tap";
|
|
||||||
id = "vm-test1";
|
|
||||||
mac = "02:00:00:00:00:01";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.network.enable = true;
|
|
||||||
|
|
||||||
systemd.network.networks."20-lan" = {
|
|
||||||
matchConfig.Type = "ether";
|
|
||||||
networkConfig = {
|
|
||||||
Address = ["10.0.0.3/24" "2001:db8::b/64"];
|
|
||||||
Gateway = "10.0.0.1";
|
|
||||||
DNS = ["1.1.1.1"];
|
|
||||||
IPv6AcceptRA = true;
|
|
||||||
DHCP = "no";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user