~dblsaiko/nix-extras

a988bb215833b77a55333b6d272937123888cf5a — Marco Rebhan 2 months ago 03755d8
nixos/nftables: Make words' drop nulls
1 files changed, 6 insertions(+), 5 deletions(-)

M nixos/ext/networking/nftables/expressions.nix
M nixos/ext/networking/nftables/expressions.nix => nixos/ext/networking/nftables/expressions.nix +6 -5
@@ 1,5 1,5 @@
{lib, ...}: let
  inherit (lib) concatStringsSep filter foldl id length mapAttrs mapAttrsToList mkMerge mkOption optional;
  inherit (lib) concatStringsSep filter flip foldl id length mapAttrs mapAttrsToList mkMerge mkOption optional pipe;
  inherit (lib.types) attrsOf enum int listOf nonEmptyListOf nullOr oneOf str submodule;
  inherit (import ./lib.nix lib) flatMap flatMapAttrsToList formatList;
  inherit (import ./types.nix lib) arp_op bitmask boolean cgroupv2 ct_dir ct_id ct_label ct_state ct_status dccp_pkttype devgroup dscp ecn ether_addr ether_type exprElemType fib_addrtype gid icmp_type icmpv6_type iface_index iface_type ifname igmp_type inet_proto inet_service ip_addr ipv4_addr ipv6_addr l4proto mark nf_proto pkt_type realm tc_handle tcp_flag time u1 u3 u4 u8 u12 u16 u20 u32 u64 uid;


@@ 27,6 27,7 @@
  prepend = what: s: "${what}${s}";
  prepend' = what: map' (prepend what);
  words = concatStringsSep " ";
  words' = flip pipe [dropNulls words];

  withIpFamily = {
    ipFamily = mkOption {


@@ 85,7 86,7 @@
      type = nullOr (enum ["loose" "skip"]);
    };
    formatter = self: config: prefix: keyword:
      words (dropNulls [prefix (prepend' "ttl " config.ttl) keyword]);
      words' [prefix (prepend' "ttl " config.ttl) keyword];
  };

  osfExpressions = fromTable [


@@ 120,14 121,14 @@
    };

    formatter = self: config: prefix: keyword:
      words (dropNulls [prefix config.direction (prepend' "spnum " (toString config.spnum)) keyword]);
      words' [prefix config.direction (prepend' "spnum " (toString config.spnum)) keyword];
  };
  withIpsecParamsAndIpFamily =
    withIpsecParams
    // withIpFamily
    // {
      formatter = self: config: prefix: keyword:
        words (dropNulls [prefix config.direction (prepend' "spnum " (toString config.spnum)) config.ipFamily keyword]);
        words' [prefix config.direction (prepend' "spnum " (toString config.spnum)) config.ipFamily keyword];
    };
  ipsecExpressions = fromTable [
    ["reqid" "request ID" u32 withIpsecParams]


@@ 283,7 284,7 @@
      type = nullOr ctDirection;
    };
    formatter = self: config: prefix: keyword:
      words (dropNulls [prefix config.direction keyword]);
      words' [prefix config.direction keyword];
  };
  withDirection = {
    direction = mkOption {