nixos-config/machines/shinobu/services/router/nft.nix

34 lines
735 B
Nix
Raw Normal View History

2023-09-24 14:41:22 +02:00
{ config, lib, ... }:
let
cfg = import ./common.nix;
mkKeyValue = lib.generators.mkKeyValueDefault
rec {
mkValueString = v:
if lib.isString v then ''"${v}"''
else if lib.isList v then ''{ ${lib.concatMapStringsSep ", " mkValueString v} }''
else lib.generators.mkValueStringDefault { } v;
} " = ";
passthru = {
WG_UPSTREAM_ENDPOINT = cfg.wg-upstream.endpoint.address;
VPN_BYPASS_MARK = cfg.vpnBypassFwMark;
};
2023-09-24 14:41:22 +02:00
defines = lib.concatStringsSep
"\n"
(lib.mapAttrsToList
(key: value: "define " + (mkKeyValue key value))
passthru);
2023-09-24 14:41:22 +02:00
in
{
networking.nftables = {
enable = true;
ruleset = ''
${defines}
include "${./rules.nft}"
'';
};
}