2020-04-24 23:36:52 +00:00
|
|
|
# Module for the IPv6 Router Advertisement Daemon.
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.radvd;
|
|
|
|
|
|
|
|
confFile = pkgs.writeText "radvd.conf" cfg.config;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
options.services.radvd = {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
enable = mkOption {
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable the Router Advertisement Daemon
|
2022-08-12 12:06:08 +00:00
|
|
|
({command}`radvd`), which provides link-local
|
2020-04-24 23:36:52 +00:00
|
|
|
advertisements of IPv6 router addresses and prefixes using
|
|
|
|
the Neighbor Discovery Protocol (NDP). This enables
|
|
|
|
stateless address autoconfiguration in IPv6 clients on the
|
|
|
|
network.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "radvd" { };
|
2022-07-14 12:49:19 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
debugLevel = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 0;
|
|
|
|
example = 5;
|
|
|
|
description = ''
|
|
|
|
The debugging level is an integer in the range from 1 to 5,
|
|
|
|
from quiet to very verbose. A debugging level of 0 completely
|
|
|
|
turns off debugging.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
config = mkOption {
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.lines;
|
2020-04-24 23:36:52 +00:00
|
|
|
example =
|
|
|
|
''
|
|
|
|
interface eth0 {
|
|
|
|
AdvSendAdvert on;
|
|
|
|
prefix 2001:db8:1234:5678::/64 { };
|
|
|
|
};
|
|
|
|
'';
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The contents of the radvd configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users.users.radvd =
|
2021-09-18 10:52:07 +00:00
|
|
|
{
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "radvd";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Router Advertisement Daemon User";
|
|
|
|
};
|
2021-09-18 10:52:07 +00:00
|
|
|
users.groups.radvd = {};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
systemd.services.radvd =
|
|
|
|
{ description = "IPv6 Router Advertisement Daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig =
|
2024-05-15 15:35:15 +00:00
|
|
|
{ ExecStart = "@${cfg.package}/bin/radvd radvd -n -u radvd -d ${toString cfg.debugLevel} -C ${confFile}";
|
2020-04-24 23:36:52 +00:00
|
|
|
Restart = "always";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|