mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-19 03:14:03 +00:00
networking/nftables: enable flushing ruleset for older versions
Co-authored-by: Naïm Favier <n@monade.li>
This commit is contained in:
parent
311d2fa994
commit
cd3af25932
@ -83,6 +83,8 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
networking.nftables.flushRuleset = mkEnableOption (lib.mdDoc "Flush the entire ruleset on each reload.");
|
||||
|
||||
networking.nftables.ruleset = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
@ -209,6 +211,7 @@ in
|
||||
boot.blacklistedKernelModules = [ "ip_tables" ];
|
||||
environment.systemPackages = [ pkgs.nftables ];
|
||||
networking.networkmanager.firewallBackend = mkDefault "nftables";
|
||||
networking.nftables.flushRuleset = mkDefault (versionOlder config.system.stateVersion "23.11");
|
||||
systemd.services.nftables = {
|
||||
description = "nftables firewall";
|
||||
before = [ "network-pre.target" ];
|
||||
@ -222,6 +225,7 @@ in
|
||||
executable = true;
|
||||
text = ''
|
||||
#! ${pkgs.nftables}/bin/nft -f
|
||||
${optionalString cfg.flushRuleset "flush ruleset"}
|
||||
${concatStringsSep "\n" (mapAttrsToList (_: table: ''
|
||||
table ${table.family} ${table.name}
|
||||
delete table ${table.family} ${table.name}
|
||||
|
Loading…
Reference in New Issue
Block a user