2020-01-07 11:52:32 -05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.services.corerad;
|
2020-12-29 15:15:32 -05:00
|
|
|
settingsFormat = pkgs.formats.toml { };
|
2020-06-07 22:41:43 -04:00
|
|
|
|
2020-01-07 11:52:32 -05:00
|
|
|
in
|
|
|
|
{
|
2024-08-28 21:19:04 +02:00
|
|
|
meta.maintainers = with lib.maintainers; [ mdlayher ];
|
2020-01-07 11:52:32 -05:00
|
|
|
|
|
|
|
options.services.corerad = {
|
2024-08-28 21:19:04 +02:00
|
|
|
enable = lib.mkEnableOption "CoreRAD IPv6 NDP RA daemon";
|
2020-01-07 11:52:32 -05:00
|
|
|
|
2024-08-28 21:19:04 +02:00
|
|
|
settings = lib.mkOption {
|
2020-12-29 15:15:32 -05:00
|
|
|
type = settingsFormat.type;
|
2024-08-28 21:19:04 +02:00
|
|
|
example = lib.literalExpression ''
|
2020-06-07 22:41:43 -04:00
|
|
|
{
|
|
|
|
interfaces = [
|
|
|
|
# eth0 is an upstream interface monitoring for IPv6 router advertisements.
|
|
|
|
{
|
|
|
|
name = "eth0";
|
|
|
|
monitor = true;
|
|
|
|
}
|
|
|
|
# eth1 is a downstream interface advertising IPv6 prefixes for SLAAC.
|
|
|
|
{
|
|
|
|
name = "eth1";
|
|
|
|
advertise = true;
|
|
|
|
prefix = [{ prefix = "::/64"; }];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
# Optionally enable Prometheus metrics.
|
|
|
|
debug = {
|
|
|
|
address = "localhost:9430";
|
|
|
|
prometheus = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
2021-07-21 10:35:48 -04:00
|
|
|
Configuration for CoreRAD, see <https://github.com/mdlayher/corerad/blob/main/internal/config/reference.toml>
|
2020-06-07 22:41:43 -04:00
|
|
|
for supported values. Ignored if configFile is set.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-08-28 21:19:04 +02:00
|
|
|
configFile = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
example = lib.literalExpression ''"''${pkgs.corerad}/etc/corerad/corerad.toml"'';
|
2020-01-07 11:52:32 -05:00
|
|
|
description = "Path to CoreRAD TOML configuration file.";
|
|
|
|
};
|
|
|
|
|
2024-08-28 21:19:04 +02:00
|
|
|
package = lib.mkPackageOption pkgs "corerad" { };
|
2020-01-07 11:52:32 -05:00
|
|
|
};
|
|
|
|
|
2024-08-28 21:19:04 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2020-06-07 22:41:43 -04:00
|
|
|
# Prefer the config file over settings if both are set.
|
2024-08-28 21:19:04 +02:00
|
|
|
services.corerad.configFile = lib.mkDefault (settingsFormat.generate "corerad.toml" cfg.settings);
|
2020-06-07 22:41:43 -04:00
|
|
|
|
2020-01-07 11:52:32 -05:00
|
|
|
systemd.services.corerad = {
|
|
|
|
description = "CoreRAD IPv6 NDP RA daemon";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
LimitNPROC = 512;
|
|
|
|
LimitNOFILE = 1048576;
|
|
|
|
CapabilityBoundingSet = "CAP_NET_ADMIN CAP_NET_RAW";
|
|
|
|
AmbientCapabilities = "CAP_NET_ADMIN CAP_NET_RAW";
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
DynamicUser = true;
|
2020-06-24 22:09:20 -04:00
|
|
|
Type = "notify";
|
|
|
|
NotifyAccess = "main";
|
2024-08-28 21:19:04 +02:00
|
|
|
ExecStart = "${lib.getBin cfg.package}/bin/corerad -c=${cfg.configFile}";
|
2020-01-07 11:52:32 -05:00
|
|
|
Restart = "on-failure";
|
2020-08-09 13:24:10 -04:00
|
|
|
RestartKillSignal = "SIGHUP";
|
2020-01-07 11:52:32 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|