add domain config

main
n0emis 3 years ago
parent ec23ebb082
commit 7334aded89
Signed by: n0emis
GPG Key ID: 00FAF748B777CF10

@ -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 = [

@ -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
}

@ -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;
};
}

Loading…
Cancel
Save