From 7334aded8900a0c9b0edda92f77d0c971fb16193 Mon Sep 17 00:00:00 2001 From: Ember 'n0emis' Keske Date: Thu, 10 Mar 2022 21:25:03 +0100 Subject: [PATCH] add domain config --- default.nix | 49 +++++++++++++++++++++++++++++++++++++++++++++- flake.lock | 42 +++++++++++++++++++++++++++++++++++++++ modules/batman.nix | 8 ++++---- 3 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 flake.lock diff --git a/default.nix b/default.nix index 873f28b..de10968 100644 --- a/default.nix +++ b/default.nix @@ -4,11 +4,12 @@ with lib; let cfg = config.ffnix; + activeDomains = attrsets.filterAttrs (n: v: v.enable) cfg.domains; in { options.ffnix = { enable = mkEnableOption "ffnix"; - batman-legacy = mkOption { + batmanLegacy = mkOption { default = false; example = true; type = types.bool; @@ -33,12 +34,58 @@ in default = ""; }; }; + domains = mkOption { + description = "Freifunk Domains (a domain is a seperated L2 network segment)"; + default = {}; + type = with types; attrsOf (submodule { + options = { + enable = mkEnableOption "ffnix Site"; + ipv4Prefix = mkOption { + type = types.str; + }; + ipv6Prefixes = mkOption { + type = types.listOf types.str; + }; + addresses = mkOption { + type = types.listOf types.str; + }; + routingTable = mkOption { + type = types.int; + }; + mtu = mkOption { + type = types.int; + }; + enableRadvd = mkOption { + default = false; + type = types.bool; + }; + radvdPrefixes = mkOption { + default = []; + type = types.listOf types.str; + }; + dhcpRange = mkOption { + default = ""; + type = types.str; + }; + searchDomains = mkOption { + default = []; + type = types.listOf types.str; + }; + tunnels = mkOption { + default = {}; + type = (pkgs.formats.json {}).type; + }; + }; + }); + }; }; config = mkIf cfg.enable { services.vnstat.enable = true; programs.mtr.enable = true; + + environment.etc."ffnix.json".source = pkgs.writeText "ffnix.json" (generators.toJSON {} activeDomains); }; imports = [ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c9e816e --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1646857268, + "narHash": "sha256-ZNfRkT+XwnYMhvzbmmV3HcK9iAarJn7BcZ2JWOaYXVU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d26d5d86827500826b0dbb713d26749a791f7be5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/modules/batman.nix b/modules/batman.nix index 95e5799..1f88273 100644 --- a/modules/batman.nix +++ b/modules/batman.nix @@ -10,11 +10,11 @@ in boot.kernelModules = [ "batman_adv" ]; boot.extraModulePackages = [] - ++ lib.optional (!cfg.batman-legacy) config.boot.kernelPackages.batman_adv - ++ lib.optional cfg.batman-legacy (pkgs.batman-adv-legacy config.boot.kernelPackages); + ++ lib.optional (!cfg.batmanLegacy) config.boot.kernelPackages.batman_adv + ++ lib.optional cfg.batmanLegacy (pkgs.batman-adv-legacy config.boot.kernelPackages); environment.systemPackages = [] - ++ lib.optional (!cfg.batman-legacy) pkgs.batctl - ++ lib.optional cfg.batman-legacy pkgs.batctl-legacy; + ++ lib.optional (!cfg.batmanLegacy) pkgs.batctl + ++ lib.optional cfg.batmanLegacy pkgs.batctl-legacy; }; }