From ced991b911f38580111e73d6409d3d0d2f0600b9 Mon Sep 17 00:00:00 2001 From: clerie Date: Thu, 8 May 2025 16:17:26 +0200 Subject: [PATCH] profiles/router: Migrate configuration to profile --- configuration/router/default.nix | 15 --------------- hosts/carbon/configuration.nix | 2 +- hosts/gatekeeper/configuration.nix | 2 +- hosts/nonat/configuration.nix | 2 +- hosts/porter/configuration.nix | 2 +- profiles/default.nix | 1 + profiles/router/default.nix | 26 ++++++++++++++++++++++++++ 7 files changed, 31 insertions(+), 19 deletions(-) delete mode 100644 configuration/router/default.nix create mode 100644 profiles/router/default.nix diff --git a/configuration/router/default.nix b/configuration/router/default.nix deleted file mode 100644 index 23541a7..0000000 --- a/configuration/router/default.nix +++ /dev/null @@ -1,15 +0,0 @@ -{ pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - wireguard-tools - tcpdump - ]; - - boot.kernel.sysctl = { - "net.ipv4.ip_forward" = true; - "net.ipv6.conf.all.forwarding" = true; - }; - - networking.firewall.checkReversePath = false; -} diff --git a/hosts/carbon/configuration.nix b/hosts/carbon/configuration.nix index 5bf6cf3..b0fc794 100644 --- a/hosts/carbon/configuration.nix +++ b/hosts/carbon/configuration.nix @@ -4,7 +4,6 @@ imports = [ ./hardware-configuration.nix - ../../configuration/router ./dns.nix ./mdns.nix @@ -23,6 +22,7 @@ ]; profiles.clerie.common-networking.enable = false; + profiles.clerie.router.enable = true; boot.kernelParams = [ "console=ttyS0,115200n8" ]; diff --git a/hosts/gatekeeper/configuration.nix b/hosts/gatekeeper/configuration.nix index 7fe8de2..ed30b6d 100644 --- a/hosts/gatekeeper/configuration.nix +++ b/hosts/gatekeeper/configuration.nix @@ -4,10 +4,10 @@ imports = [ ./hardware-configuration.nix - ../../configuration/router ]; profiles.clerie.hetzner-cloud.enable = true; + profiles.clerie.router.enable = true; boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; diff --git a/hosts/nonat/configuration.nix b/hosts/nonat/configuration.nix index 47d7495..dfee059 100644 --- a/hosts/nonat/configuration.nix +++ b/hosts/nonat/configuration.nix @@ -4,10 +4,10 @@ imports = [ ./hardware-configuration.nix - ../../configuration/router ]; profiles.clerie.mercury-vm.enable = true; + profiles.clerie.router.enable = true; boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; diff --git a/hosts/porter/configuration.nix b/hosts/porter/configuration.nix index d4a24a3..2e236c2 100644 --- a/hosts/porter/configuration.nix +++ b/hosts/porter/configuration.nix @@ -4,10 +4,10 @@ imports = [ ./hardware-configuration.nix - ../../configuration/router ]; profiles.clerie.netcup.enable = true; + profiles.clerie.router.enable = true; boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; diff --git a/profiles/default.nix b/profiles/default.nix index 52a6699..a7ae051 100644 --- a/profiles/default.nix +++ b/profiles/default.nix @@ -14,6 +14,7 @@ ./mercury-vm ./netcup ./network-fallback-dhcp + ./router ./ruby-vm ./serial-console ./wg-clerie diff --git a/profiles/router/default.nix b/profiles/router/default.nix new file mode 100644 index 0000000..11a7a51 --- /dev/null +++ b/profiles/router/default.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + + options.profiles.clerie.router = { + enable = mkEnableOption "Basic router setup"; + }; + + config = mkIf config.profiles.clerie.router.enable { + + environment.systemPackages = with pkgs; [ + wireguard-tools + tcpdump + ]; + + boot.kernel.sysctl = { + "net.ipv4.ip_forward" = true; + "net.ipv6.conf.all.forwarding" = true; + }; + + networking.firewall.checkReversePath = false; + + }; +}