1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat(wireguard): add ability to automatically assign addresses

This commit is contained in:
oddlama 2023-05-29 00:07:56 +02:00
parent 4e8103af47
commit c789e2de36
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
8 changed files with 136 additions and 47 deletions

View file

@ -231,7 +231,7 @@
};
in
assert lib.assertMsg (cidrSize >= 2 && cidrSize <= 62)
"assignIps: cidrSize=${cidrSize} is not in [2, 62].";
"assignIps: cidrSize=${toString cidrSize} is not in [2, 62].";
assert lib.assertMsg (nHosts <= capacity - nInit)
"assignIps: number of hosts (${toString nHosts}) must be <= capacity (${toString capacity}) - reserved (${toString nInit})";
# Assign an ip in the subnet to each element, in order
@ -242,7 +242,9 @@
sortedHosts)
.assigned;
};
ip = {
ip = rec {
# Checks whether the given address (with or without cidr notation) is an ipv4 address.
isv4 = x: !isv6 x;
# Checks whether the given address (with or without cidr notation) is an ipv6 address.
isv6 = lib.hasInfix ":";
};

View file

@ -25,6 +25,13 @@ in {
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "sdhci_pci" "r8169"];
extra.wireguard.proxy-sentinel.server = {
host = "TODO REMOVE";
port = 51443;
reservedAddresses = ["10.0.43.0/24" "fd43::/120"];
openFirewallRules = ["untrusted-to-local"];
};
extra.microvms.vms = let
defineVm = id: {
inherit id;