8 cfg = config.services.corerad;
9 settingsFormat = pkgs.formats.toml { };
13 meta.maintainers = with lib.maintainers; [ mdlayher ];
15 options.services.corerad = {
16 enable = lib.mkEnableOption "CoreRAD IPv6 NDP RA daemon";
18 settings = lib.mkOption {
19 type = settingsFormat.type;
20 example = lib.literalExpression ''
23 # eth0 is an upstream interface monitoring for IPv6 router advertisements.
28 # eth1 is a downstream interface advertising IPv6 prefixes for SLAAC.
32 prefix = [{ prefix = "::/64"; }];
35 # Optionally enable Prometheus metrics.
37 address = "localhost:9430";
43 Configuration for CoreRAD, see <https://github.com/mdlayher/corerad/blob/main/internal/config/reference.toml>
44 for supported values. Ignored if configFile is set.
48 configFile = lib.mkOption {
49 type = lib.types.path;
50 example = lib.literalExpression ''"''${pkgs.corerad}/etc/corerad/corerad.toml"'';
51 description = "Path to CoreRAD TOML configuration file.";
54 package = lib.mkPackageOption pkgs "corerad" { };
57 config = lib.mkIf cfg.enable {
58 # Prefer the config file over settings if both are set.
59 services.corerad.configFile = lib.mkDefault (settingsFormat.generate "corerad.toml" cfg.settings);
61 systemd.services.corerad = {
62 description = "CoreRAD IPv6 NDP RA daemon";
63 after = [ "network.target" ];
64 wantedBy = [ "multi-user.target" ];
67 LimitNOFILE = 1048576;
68 CapabilityBoundingSet = "CAP_NET_ADMIN CAP_NET_RAW";
69 AmbientCapabilities = "CAP_NET_ADMIN CAP_NET_RAW";
70 NoNewPrivileges = true;
73 NotifyAccess = "main";
74 ExecStart = "${lib.getBin cfg.package}/bin/corerad -c=${cfg.configFile}";
75 Restart = "on-failure";
76 RestartKillSignal = "SIGHUP";