diff options
author | jerrita <je5r1ta@icloud.com> | 2024-02-03 09:47:54 +0800 |
---|---|---|
committer | jerrita <je5r1ta@icloud.com> | 2024-02-05 11:27:16 +0800 |
commit | e686847d206428b68b53a9da3b79ffbf6b2c8d7f (patch) | |
tree | 65ea856ea9b1c921d8ca0766f7af6a9fb4569192 /nixos/modules/services/networking | |
parent | 758e589e5d9054d50afc19aab67b59f9d6029fe3 (diff) | |
download | nixlib-e686847d206428b68b53a9da3b79ffbf6b2c8d7f.tar nixlib-e686847d206428b68b53a9da3b79ffbf6b2c8d7f.tar.gz nixlib-e686847d206428b68b53a9da3b79ffbf6b2c8d7f.tar.bz2 nixlib-e686847d206428b68b53a9da3b79ffbf6b2c8d7f.tar.lz nixlib-e686847d206428b68b53a9da3b79ffbf6b2c8d7f.tar.xz nixlib-e686847d206428b68b53a9da3b79ffbf6b2c8d7f.tar.zst nixlib-e686847d206428b68b53a9da3b79ffbf6b2c8d7f.zip |
nixos/nftables: add option for flattening rulesetFile
Co-authored-by: Lin Jian <me@linj.tech>
Diffstat (limited to 'nixos/modules/services/networking')
-rw-r--r-- | nixos/modules/services/networking/nftables.nix | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/nftables.nix b/nixos/modules/services/networking/nftables.nix index 424d005dc0b5..36d006808347 100644 --- a/nixos/modules/services/networking/nftables.nix +++ b/nixos/modules/services/networking/nftables.nix @@ -185,6 +185,19 @@ in can be loaded using "nft -f". The ruleset is updated atomically. ''; }; + + networking.nftables.flattenRulesetFile = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc '' + Use `builtins.readFile` rather than `include` to handle {option}`networking.nftables.rulesetFile`. It is useful when you want to apply {option}`networking.nftables.preCheckRuleset` to {option}`networking.nftables.rulesetFile`. + + ::: {.note} + It is expected that {option}`networking.nftables.rulesetFile` can be accessed from the build sandbox. + ::: + ''; + }; + networking.nftables.tables = mkOption { type = types.attrsOf (types.submodule tableSubmodule); @@ -293,9 +306,13 @@ in } '') enabledTables)} ${cfg.ruleset} - ${lib.optionalString (cfg.rulesetFile != null) '' - include "${cfg.rulesetFile}" - ''} + ${if cfg.rulesetFile != null then + if cfg.flattenRulesetFile then + builtins.readFile cfg.rulesetFile + else '' + include "${cfg.rulesetFile}" + '' + else ""} ''; checkPhase = lib.optionalString cfg.checkRuleset '' cp $out ruleset.conf |