shinobu/router: Change nft variable source

This commit is contained in:
Simon Bruder 2023-09-25 12:48:30 +02:00
parent f6694ebb8c
commit 7a7b385b44
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
2 changed files with 8 additions and 9 deletions

View file

@ -2,23 +2,24 @@
let let
cfg = import ./common.nix; cfg = import ./common.nix;
flattenAttrValues = attrs: lib.flatten (map (v: if lib.isAttrs v then flattenAttrValues v else v) (lib.attrValues attrs));
mkKeyValue = lib.generators.mkKeyValueDefault mkKeyValue = lib.generators.mkKeyValueDefault
rec { rec {
# specifies the generated string for a subset of nix values
mkValueString = v: mkValueString = v:
if lib.isString v then ''"${v}"'' if lib.isString v then ''"${v}"''
else if lib.isList v then ''{ ${lib.concatMapStringsSep ", " mkValueString v} }'' else if lib.isList v then ''{ ${lib.concatMapStringsSep ", " mkValueString v} }''
else lib.generators.mkValueStringDefault { } v; else lib.generators.mkValueStringDefault { } v;
} " = "; } " = ";
passthru = {
WG_UPSTREAM_ENDPOINT = cfg.wg-upstream.endpoint.address;
VPN_BYPASS_MARK = cfg.vpnBypassFwMark;
};
defines = lib.concatStringsSep defines = lib.concatStringsSep
"\n" "\n"
(flattenAttrValues (lib.mapAttrsToList
(lib.mapAttrsRecursive (key: value: "define " + (mkKeyValue key value))
(path: value: "define " + (mkKeyValue ''CFG_${lib.concatStringsSep "_" path}'' value)) passthru);
cfg));
in in
{ {
networking.nftables = { networking.nftables = {

View file

@ -5,9 +5,7 @@ define MASQUERADE_IFACES = { $NAT_WAN_IFACES, $PHYSICAL_WAN }
define VUEKO_V4 = 168.119.176.53 define VUEKO_V4 = 168.119.176.53
define VUEKO_V6 = 2a01:4f8:c012:2f4::1 define VUEKO_V6 = 2a01:4f8:c012:2f4::1
define VUEKO_PORT = 51820 define VUEKO_PORT = 51820
define WG_UPSTREAM_ENDPOINT = $CFG_wg-upstream_endpoint_address
define PLASTIC_ROUTER_V4 = 192.168.0.1 define PLASTIC_ROUTER_V4 = 192.168.0.1
define VPN_BYPASS_MARK = $CFG_vpnBypassFwMark
table inet filter { table inet filter {
chain forward { chain forward {