9 cfg = config.services.babeld;
11 conditionalBoolToString =
12 value: if (lib.isBool value) then (lib.boolToString value) else (toString value);
16 lib.concatMapStringsSep " " (name: "${name} ${conditionalBoolToString (lib.getAttr name params)}") (
23 interface = lib.getAttr name cfg.interfaces;
25 "interface ${name} ${paramsString interface}\n";
29 pkgs.writeText "babeld.conf" (
31 skip-kernel-setup true
33 + (lib.optionalString (cfg.interfaceDefaults != null) ''
34 default ${paramsString cfg.interfaceDefaults}
36 + (lib.concatMapStrings interfaceConfig (lib.attrNames cfg.interfaces))
44 meta.maintainers = with lib.maintainers; [ hexa ];
52 enable = lib.mkEnableOption "the babeld network routing daemon";
54 interfaceDefaults = lib.mkOption {
57 A set describing default parameters for babeld interfaces.
58 See {manpage}`babeld(8)` for options.
60 type = lib.types.nullOr (lib.types.attrsOf lib.types.unspecified);
67 interfaces = lib.mkOption {
70 A set describing babeld interfaces.
71 See {manpage}`babeld(8)` for options.
73 type = lib.types.attrsOf (lib.types.attrsOf lib.types.unspecified);
78 split-horizon = "auto";
83 extraConfig = lib.mkOption {
85 type = lib.types.lines;
87 Options that will be copied to babeld.conf.
88 See {manpage}`babeld(8)` for details.
97 config = lib.mkIf config.services.babeld.enable {
101 "net.ipv6.conf.all.forwarding" = 1;
102 "net.ipv6.conf.all.accept_redirects" = 0;
103 "net.ipv4.conf.all.forwarding" = 1;
104 "net.ipv4.conf.all.rp_filter" = 0;
107 ifname: _: lib.nameValuePair "net.ipv4.conf.${ifname}.rp_filter" (lib.mkDefault 0)
108 ) config.services.babeld.interfaces;
110 systemd.services.babeld = {
111 description = "Babel routing daemon";
112 after = [ "network.target" ];
113 wantedBy = [ "multi-user.target" ];
115 ExecStart = "${pkgs.babeld}/bin/babeld -c ${configFile} -I /run/babeld/babeld.pid -S /var/lib/babeld/state";
116 AmbientCapabilities = [ "CAP_NET_ADMIN" ];
117 CapabilityBoundingSet = [ "CAP_NET_ADMIN" ];
118 DevicePolicy = "closed";
126 IPAddressDeny = "any";
127 LockPersonality = true;
128 NoNewPrivileges = true;
129 MemoryDenyWriteExecute = true;
130 ProtectSystem = "strict";
132 ProtectKernelTunables = true;
133 ProtectKernelModules = true;
134 ProtectKernelLogs = true;
135 ProtectControlGroups = true;
136 RestrictAddressFamilies = [
141 RestrictNamespaces = true;
142 RestrictRealtime = true;
143 RestrictSUIDSGID = true;
146 ProtectHostname = true;
147 ProtectProc = "invisible";
148 PrivateMounts = true;
150 PrivateDevices = true;
151 PrivateUsers = false; # kernel_route(ADD): Operation not permitted
153 SystemCallArchitectures = "native";
156 "~@privileged @resources"
159 RuntimeDirectory = "babeld";
160 StateDirectory = "babeld";