hosts: server: microvm nat

This commit is contained in:
Kabbone 2024-01-21 09:54:32 +01:00
parent f4eb08097a
commit 4a876f27d3
Signed by: Kabbone
SSH Key Fingerprint: SHA256:A5zPB5I6u5V78V51c362BBdCwhDhfDUVbt7NfKdjWBY

View File

@ -1,8 +1,45 @@
{ config, microvm, nixpkgs, user, agenix, impermanence, ... }: { config, microvm, lib, pkgs, user, agenix, impermanence, ... }:
let let
name = "gitea-runner"; name = "gitea-runner";
in in
{ {
systemd.network = {
enable = true;
netdevs."10-microvm".netdevConfig = {
Kind = "bridge";
Name = "microvm";
};
networks = {
"10-microvm" = {
matchConfig.Name = "microvm";
networkConfig = {
DHCP = "yes";
IPv6AcceptRA = true;
};
addresses = [ {
addressConfig.Address = "10.0.0.1/24";
} {
addressConfig.Address = "fd12:3456:789a::1/64";
} ];
ipv6Prefixes = [ {
ipv6PrefixConfig.Prefix = "fd12:3456:789a::/64";
} ];
};
"11-microvm" = {
matchConfig.Name = "vm-*";
networkConfig.Bridge = "microvm";
};
};
};
networking = {
nat = {
enable = true;
enableIPv6 = true;
externalInterface = "ens18";
internalInterfaces = [ "microvm" ];
};
};
microvm = { microvm = {
autostart = [ autostart = [
name name
@ -10,12 +47,14 @@ in
vms = { vms = {
${name} = { ${name} = {
pkgs = import nixpkgs { inherit pkgs;
system = "x86_64-linux";
config.allowUnfree = true;
};
config = { config = {
#pkgs = import nixpkgs {
# system = "x86_64-linux";
# config.allowUnfree = true;
#};
imports = imports =
[ agenix.nixosModules.default ] ++ [ agenix.nixosModules.default ] ++
[ impermanence.nixosModules.impermanence ] ++ [ impermanence.nixosModules.impermanence ] ++
@ -43,6 +82,7 @@ in
}; };
}; };
users.users.${user} = { # System User users.users.${user} = { # System User
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
@ -71,7 +111,7 @@ in
}; };
}; };
fileSystems."/persist".neededForBoot = nixpkgs.lib.mkForce true; fileSystems."/persist".neededForBoot = lib.mkForce true;
environment.persistence."/persist" = { environment.persistence."/persist" = {
directories = [ directories = [
@ -88,6 +128,8 @@ in
hypervisor = "cloud-hypervisor"; hypervisor = "cloud-hypervisor";
vcpu = 4; vcpu = 4;
mem = 4096; mem = 4096;
balloonMem = 4096;
#kernel = pkgs.linuxKernel.packages.linux_latest;
interfaces = [ interfaces = [
{ {
type = "macvtap"; type = "macvtap";