2024-11-13 05:15:14 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: let
|
2024-11-13 20:27:18 +01:00
|
|
|
prefix = "lyn";
|
2024-11-12 01:49:31 +01:00
|
|
|
|
|
|
|
#define wireguard subnets
|
|
|
|
wg_subnets = {
|
2024-11-13 18:43:06 +01:00
|
|
|
IPv4 = "10.35.0.1/24";
|
|
|
|
IPv6 = "fd1a:acab:cafe:1337::/64";
|
2024-11-12 01:49:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#Below is where all hosts are defined
|
|
|
|
hosts = {
|
|
|
|
wg-gateway = {
|
|
|
|
wg = {
|
|
|
|
enabled = true;
|
|
|
|
pubkey = "lol";
|
|
|
|
port = 51820;
|
|
|
|
};
|
|
|
|
v4 = {
|
|
|
|
public = "78.47.226.47";
|
|
|
|
# we use 10.35.0.0/16 as a range for private subnets, specifically 10.35.0.0/24 for wireguard peers
|
|
|
|
internal = "10.35.0.1";
|
|
|
|
};
|
|
|
|
v6 = {
|
|
|
|
public = "2a01:4f8:1c1b:d2db::";
|
|
|
|
# 1aacabcafe is the global ID and 1337 is the wireguard peer subnet ID, resulting in the ULA fd1a:acab:cafe:1337::/64
|
|
|
|
internal = "fd1a:acab:cafe:1337:8f4c:68cd";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
supernova = {
|
|
|
|
wg = {
|
|
|
|
enabled = true;
|
|
|
|
pubkey = "lol";
|
|
|
|
port = 51820;
|
|
|
|
};
|
|
|
|
v4 = {
|
|
|
|
public = "";
|
|
|
|
# we use 10.35.0.0/16 as a range for private subnets, specifically 10.35.0.0/24 for wireguard peers
|
|
|
|
internal = "10.35.0.2";
|
|
|
|
};
|
|
|
|
v6 = {
|
|
|
|
public = "";
|
|
|
|
# 1aacabcafe is the global ID and 1337 is the wireguard peer subnet ID, resulting in the ULA fd1a:acab:cafe:1337::/64
|
|
|
|
internal = "fd1a:acab:cafe:1337:6722:3657";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in {
|
2024-11-13 05:15:14 +01:00
|
|
|
options = {
|
2024-11-13 18:43:06 +01:00
|
|
|
${prefix} = {
|
|
|
|
network.wg_subnets.IPv4 = lib.mkOption {
|
2024-11-13 20:04:25 +01:00
|
|
|
type = lib.types.str;
|
2024-11-13 18:43:06 +01:00
|
|
|
description = "The IPv6 range that wireguard peers will use";
|
2024-11-13 05:15:14 +01:00
|
|
|
};
|
2024-11-13 18:43:06 +01:00
|
|
|
network.wg_subnets.IPv6 = lib.mkOption {
|
2024-11-13 20:04:25 +01:00
|
|
|
type = lib.types.str;
|
2024-11-13 18:43:06 +01:00
|
|
|
description = "The IPv4 range that wireguard peers will use";
|
2024-11-13 05:15:14 +01:00
|
|
|
};
|
2024-11-13 19:19:13 +01:00
|
|
|
|
|
|
|
# defining the entire hosts part as a module
|
2024-11-13 05:15:14 +01:00
|
|
|
network.hosts = lib.mkOption {
|
2024-11-13 19:21:57 +01:00
|
|
|
type = lib.types.attrsOf (lib.types.submodule {
|
2024-11-13 19:19:13 +01:00
|
|
|
options = {
|
|
|
|
wg = lib.mkOption {
|
|
|
|
type = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
enabled = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable WireGuard";
|
|
|
|
};
|
|
|
|
pubkey = lib.mkOption {
|
2024-11-13 20:04:25 +01:00
|
|
|
type = lib.types.nullOr lib.types.str;
|
2024-11-13 19:19:13 +01:00
|
|
|
default = null;
|
|
|
|
description = "Public key for WireGuard";
|
|
|
|
};
|
|
|
|
port = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
|
|
|
default = 51820;
|
|
|
|
description = "Port for WireGuard";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
description = "WireGuard configuration";
|
|
|
|
};
|
|
|
|
v4 = lib.mkOption {
|
|
|
|
type = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
public = lib.mkOption {
|
2024-11-13 20:04:25 +01:00
|
|
|
type = lib.types.nullOr lib.types.str;
|
2024-11-13 19:19:13 +01:00
|
|
|
default = null;
|
|
|
|
description = "Public IPv4 address";
|
|
|
|
};
|
|
|
|
internal = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Wireguard-internal IPv4 address";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
description = "IPv4 configuration";
|
2024-11-13 20:04:25 +01:00
|
|
|
default = {};
|
2024-11-13 19:19:13 +01:00
|
|
|
};
|
|
|
|
v6 = lib.mkOption {
|
|
|
|
type = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
public = lib.mkOption {
|
2024-11-13 20:04:25 +01:00
|
|
|
type = lib.types.nullOr lib.types.str;
|
2024-11-13 19:19:13 +01:00
|
|
|
description = "Public IPv6 address";
|
|
|
|
};
|
|
|
|
internal = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Wireguard-internal IPv6 address";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
description = "IPv6 configuration";
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
default = {};
|
2024-11-13 05:15:14 +01:00
|
|
|
description = "All hosts in this network that this config should be aware of";
|
|
|
|
};
|
2024-11-12 01:49:31 +01:00
|
|
|
};
|
2024-11-13 20:27:18 +01:00
|
|
|
};
|
|
|
|
${prefix}.network = {
|
|
|
|
inherit hosts wg_subnets;
|
2024-11-12 01:49:31 +01:00
|
|
|
};
|
|
|
|
}
|