summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-04-24 22:04:42 +0200
committerMel <mel@rnrd.eu>2026-04-24 22:04:42 +0200
commit127d8ff2c2e77a0cbfc7a2a3c962ef23b5ab7261 (patch)
tree8c1466f92c26fb08ea6c2c3d666cacc7fe372cb6
parent0bfba3b356635a296f22bd060537c6c74cef2635 (diff)
downloadnetwork-127d8ff2c2e77a0cbfc7a2a3c962ef23b5ab7261.tar.zst
network-127d8ff2c2e77a0cbfc7a2a3c962ef23b5ab7261.zip
Remove generic foundation WireGuard server module, currently replaced by the tunnel and not required
Signed-off-by: Mel <mel@rnrd.eu>
-rw-r--r--machines/corsac/devices.nix1
-rw-r--r--machines/fourmi/devices.nix2
-rw-r--r--machines/lapin/devices.nix2
-rw-r--r--machines/renard/devices.nix2
-rw-r--r--machines/taureau/devices.nix2
-rw-r--r--machines/truite/devices.nix2
-rw-r--r--modules/foundation/default.nix1
-rw-r--r--modules/foundation/wireguard.nix130
8 files changed, 5 insertions, 137 deletions
diff --git a/machines/corsac/devices.nix b/machines/corsac/devices.nix
index 06e4f8c..a2215fd 100644
--- a/machines/corsac/devices.nix
+++ b/machines/corsac/devices.nix
@@ -8,7 +8,6 @@
efi.canTouchEfiVariables = true;
};
- kernelModules = [ "wireguard" ];
initrd.systemd.enable = true;
};
diff --git a/machines/fourmi/devices.nix b/machines/fourmi/devices.nix
index 342e89f..c8d2e72 100644
--- a/machines/fourmi/devices.nix
+++ b/machines/fourmi/devices.nix
@@ -24,7 +24,7 @@
};
plymouth.enable = true;
- kernelModules = [ "wireguard" ];
+ kernelModules = [ ];
};
zramSwap = {
diff --git a/machines/lapin/devices.nix b/machines/lapin/devices.nix
index ccf7d75..450baf3 100644
--- a/machines/lapin/devices.nix
+++ b/machines/lapin/devices.nix
@@ -3,7 +3,7 @@
{
boot = {
loader.systemd-boot.enable = true;
- kernelModules = [ "wireguard" ];
+ kernelModules = [ ];
};
# testing with replacing swap partitions
diff --git a/machines/renard/devices.nix b/machines/renard/devices.nix
index 6965d7d..aa8d7b9 100644
--- a/machines/renard/devices.nix
+++ b/machines/renard/devices.nix
@@ -3,7 +3,7 @@
{
boot.initrd = {
availableKernelModules = [ "virtio_pci" "virtio_scsi" ];
- kernelModules = [ "dm-snapshot" "wireguard" ];
+ kernelModules = [ "dm-snapshot" ];
};
boot.loader.grub = {
diff --git a/machines/taureau/devices.nix b/machines/taureau/devices.nix
index b48c84b..856dcf1 100644
--- a/machines/taureau/devices.nix
+++ b/machines/taureau/devices.nix
@@ -7,7 +7,7 @@
device = "/dev/sda";
};
- kernelModules = [ "wireguard" ];
+ kernelModules = [ ];
};
networking = {
diff --git a/machines/truite/devices.nix b/machines/truite/devices.nix
index 3d8bfce..bc432c1 100644
--- a/machines/truite/devices.nix
+++ b/machines/truite/devices.nix
@@ -7,7 +7,7 @@
device = "/dev/sda";
};
- kernelModules = [ "wireguard" ];
+ kernelModules = [ ];
};
zramSwap = {
diff --git a/modules/foundation/default.nix b/modules/foundation/default.nix
index 68e102a..3905eb8 100644
--- a/modules/foundation/default.nix
+++ b/modules/foundation/default.nix
@@ -3,7 +3,6 @@
{
imports = [
./tailnet.nix
- ./wireguard.nix
./services
./monitoring
./www
diff --git a/modules/foundation/wireguard.nix b/modules/foundation/wireguard.nix
deleted file mode 100644
index 366a353..0000000
--- a/modules/foundation/wireguard.nix
+++ /dev/null
@@ -1,130 +0,0 @@
-{
- config,
- pkgs,
- lib,
- ...
-}:
-
-let
- inherit (pkgs) iptables;
-
- inherit (lib)
- mkIf
- mkEnableOption
- mkOption
- assertMsg
- types
- ;
-
- cfg = config.foundation.wireguard;
-
- # TODO: we might want to configure these through options?
-
- wireguardPort = 51820;
- wireguardIPv4 = number: subnet: "10.123.10.${number}/${subnet}";
- wireguardIPv6 = number: subnet: "fd0f:123::${number}/${subnet}";
-
- wireguardInterface = "wg0";
-in
-{
- options.foundation.wireguard =
- let
- peerSubmodule =
- with types;
- submodule {
- options = {
- ip = mkOption {
- type = int;
- };
-
- key = mkOption {
- type = str;
- };
- };
- };
- in
- {
- server = {
- enable = mkEnableOption "wireguard vpn server";
-
- externalInterface = mkOption {
- type = types.str;
- default = "eth0";
- };
-
- peers = mkOption {
- type = types.attrsOf peerSubmodule;
- default = { };
- };
- };
- };
-
- config = mkIf cfg.server.enable {
- age.secrets.wireguard-private-key = {
- file = ../../secrets/wireguard-private-key.age;
- };
-
- # enable nat, to rename internal wireguard ips to external ip (w/ iptables)
- networking = {
- nat = {
- enable = true;
- internalInterfaces = [ wireguardInterface ];
- inherit (cfg.server) externalInterface;
- };
-
- firewall = {
- allowedUDPPorts = [ wireguardPort ];
- };
- };
-
- # enable kernel support for ipv6 forwarding
- boot.kernel.sysctl = {
- "net.ipv6.conf.all.forwarding" = 1;
- "net.ipv6.conf.default.forwarding" = 1;
- };
-
- networking.wireguard.interfaces.${wireguardInterface} =
- let
- inherit (cfg.server) externalInterface;
-
- peerIPs = peerNumber: [
- (wireguardIPv4 peerNumber "32")
- (wireguardIPv6 peerNumber "128")
- ];
-
- mkPeer =
- p:
- assert assertMsg (p.ip > 1) "ip has to be larger that 1";
- {
- allowedIPs = peerIPs (toString p.ip);
- publicKey = p.key;
- };
- peers = map mkPeer (builtins.attrValues cfg.server.peers);
- in
- {
- inherit peers;
-
- # ip address of server + subnet of network
- ips = [
- (wireguardIPv4 "1" "24")
- (wireguardIPv6 "1" "112")
- ];
- listenPort = wireguardPort;
-
- # route wireguard traffic to the internet
- # also requires clients to have dns set. (i think)
- # to avoid, maybe? use wg-quick + dnsmasq?
- postSetup = ''
- ${iptables}/bin/iptables -t nat -A POSTROUTING -s ${wireguardIPv4 "0" "24"} -o ${externalInterface} -j MASQUERADE
- ${iptables}/bin/ip6tables -t nat -A POSTROUTING -s ${wireguardIPv6 "0" "112"} -o ${externalInterface} -j MASQUERADE
- '';
-
- postShutdown = ''
- ${iptables}/bin/iptables -t nat -D POSTROUTING -s ${wireguardIPv4 "0" "24"} -o ${externalInterface} -j MASQUERADE
- ${iptables}/bin/ip6tables -t nat -D POSTROUTING -s ${wireguardIPv6 "0" "112"} -o ${externalInterface} -j MASQUERADE
- '';
-
- privateKeyFile = config.age.secrets.wireguard-private-key.path;
- };
- };
-}