From 9056f6dcdba1edeee08212f3125a02f18b82a39d Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Fri, 16 Oct 2026 19:15:55 -0400 Subject: [PATCH] mod: firewall changes --- modules/machine/cloud/configuration.nix | 5 ++++- modules/networking/core.nix | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/machine/cloud/configuration.nix b/modules/machine/cloud/configuration.nix index d5fe10e..b2e3f8e 100644 --- a/modules/machine/cloud/configuration.nix +++ b/modules/machine/cloud/configuration.nix @@ -151,7 +151,10 @@ in { # Core networking module (see ../../networking/core.nix) network = { - firewall.enable = true; + firewall = { + enable = true; + firewalld.enable = true; + }; networkManager.enable = true; }; diff --git a/modules/networking/core.nix b/modules/networking/core.nix index dc65e10..68bedd1 100644 --- a/modules/networking/core.nix +++ b/modules/networking/core.nix @@ -8,6 +8,12 @@ in { options.network = { firewall = { enable = lib.mkEnableOption "system firewall"; + firewalld.enable = lib.mkEnableOption "firewalld with its nftables backend"; + nftables.extraConfig = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Rules inside a separate inet nftables table alongside firewalld"; + }; tcpPorts = { ssh.enable = lib.mkEnableOption "SSH service port (22)"; web.enable = lib.mkEnableOption "common web service ports (80, 443)"; @@ -42,6 +48,21 @@ in { }; }; config = { + assertions = [ + { + assertion = cfg.firewall.nftables.extraConfig == "" || cfg.firewall.firewalld.enable; + message = "network.firewall.nftables.extraConfig requires network.firewall.firewalld.enable"; + } + ]; + services.firewalld.enable = cfg.firewall.firewalld.enable; + networking.nftables = lib.mkIf cfg.firewall.firewalld.enable { + enable = true; + flushRuleset = false; + tables."local-extra" = lib.mkIf (cfg.firewall.nftables.extraConfig != "") { + family = "inet"; + content = cfg.firewall.nftables.extraConfig; + }; + }; networking.firewall = { enable = cfg.firewall.enable; allowedTCPPorts = lib.flatten [ -- 2.54.0