1 { config, lib, pkgs, ... }:
6 cfg = config.services.corerad;
7 settingsFormat = pkgs.formats.toml {};
10 meta.maintainers = with maintainers; [ mdlayher ];
12 options.services.corerad = {
13 enable = mkEnableOption (lib.mdDoc "CoreRAD IPv6 NDP RA daemon");
16 type = settingsFormat.type;
17 example = literalExpression ''
20 # eth0 is an upstream interface monitoring for IPv6 router advertisements.
25 # eth1 is a downstream interface advertising IPv6 prefixes for SLAAC.
29 prefix = [{ prefix = "::/64"; }];
32 # Optionally enable Prometheus metrics.
34 address = "localhost:9430";
39 description = lib.mdDoc ''
40 Configuration for CoreRAD, see <https://github.com/mdlayher/corerad/blob/main/internal/config/reference.toml>
41 for supported values. Ignored if configFile is set.
45 configFile = mkOption {
47 example = literalExpression ''"''${pkgs.corerad}/etc/corerad/corerad.toml"'';
48 description = lib.mdDoc "Path to CoreRAD TOML configuration file.";
52 default = pkgs.corerad;
53 defaultText = literalExpression "pkgs.corerad";
55 description = lib.mdDoc "CoreRAD package to use.";
59 config = mkIf cfg.enable {
60 # Prefer the config file over settings if both are set.
61 services.corerad.configFile = mkDefault (settingsFormat.generate "corerad.toml" cfg.settings);
63 systemd.services.corerad = {
64 description = "CoreRAD IPv6 NDP RA daemon";
65 after = [ "network.target" ];
66 wantedBy = [ "multi-user.target" ];
69 LimitNOFILE = 1048576;
70 CapabilityBoundingSet = "CAP_NET_ADMIN CAP_NET_RAW";
71 AmbientCapabilities = "CAP_NET_ADMIN CAP_NET_RAW";
72 NoNewPrivileges = true;
75 NotifyAccess = "main";
76 ExecStart = "${getBin cfg.package}/bin/corerad -c=${cfg.configFile}";
77 Restart = "on-failure";
78 RestartKillSignal = "SIGHUP";