From 0c032a628cdfdf2d5f5e237939967fc783d1b518 Mon Sep 17 00:00:00 2001 From: marius david Date: Sun, 15 Dec 2024 09:15:44 +0100 Subject: [PATCH] services.flannel: add an extraNetworkConfig configuration, add br_netfilter kernel module --- nixos/modules/services/networking/flannel.nix | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/networking/flannel.nix b/nixos/modules/services/networking/flannel.nix index 95ad9d8374c0..08f07902f7af 100644 --- a/nixos/modules/services/networking/flannel.nix +++ b/nixos/modules/services/networking/flannel.nix @@ -7,13 +7,15 @@ let cfg = config.services.flannel; - networkConfig = lib.filterAttrs (n: v: v != null) { - Network = cfg.network; - SubnetLen = cfg.subnetLen; - SubnetMin = cfg.subnetMin; - SubnetMax = cfg.subnetMax; - Backend = cfg.backend; - }; + networkConfig = + (lib.filterAttrs (n: v: v != null) { + Network = cfg.network; + SubnetLen = cfg.subnetLen; + SubnetMin = cfg.subnetMin; + SubnetMax = cfg.subnetMax; + Backend = cfg.backend; + }) + // cfg.extraNetworkConfig; in { options.services.flannel = { @@ -139,6 +141,15 @@ in Type = "vxlan"; }; }; + + extraNetworkConfig = lib.mkOption { + description = "Extra configuration to be added to the net-conf.json/etcd-backed network configuration."; + type = (pkgs.formats.json { }).type; + default = { }; + example = { + EnableIPv6 = true; + }; + }; }; config = lib.mkIf cfg.enable { @@ -184,6 +195,8 @@ in }; }; + boot.kernelModules = [ "br_netfilter" ]; + services.etcd.enable = lib.mkDefault ( cfg.storageBackend == "etcd" && cfg.etcd.endpoints == [ "http://127.0.0.1:2379" ] );