2011-02-19 19:19:55 +00:00
|
|
|
# Module for the IPv6 Router Advertisement Daemon.
|
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-02-19 19:19:55 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2011-02-19 19:19:55 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.radvd;
|
|
|
|
|
|
|
|
confFile = pkgs.writeText "radvd.conf" cfg.config;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2022-06-30 18:35:53 +00:00
|
|
|
options.services.radvd = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2022-06-30 18:35:53 +00:00
|
|
|
enable = mkOption {
|
2020-04-20 18:05:26 +00:00
|
|
|
type = types.bool;
|
2011-02-19 19:19:55 +00:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable the Router Advertisement Daemon
|
|
|
|
({command}`radvd`), which provides link-local
|
|
|
|
advertisements of IPv6 router addresses and prefixes using
|
|
|
|
the Neighbor Discovery Protocol (NDP). This enables
|
|
|
|
stateless address autoconfiguration in IPv6 clients on the
|
|
|
|
network.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-11-27 00:19:27 +00:00
|
|
|
package = mkPackageOption pkgs "radvd" { };
|
2022-06-30 18:35:53 +00:00
|
|
|
|
2024-05-02 04:09:52 +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-06-30 18:35:53 +00:00
|
|
|
config = mkOption {
|
2021-01-31 12:54:30 +00:00
|
|
|
type = types.lines;
|
2011-02-19 19:19:55 +00:00
|
|
|
example =
|
|
|
|
''
|
|
|
|
interface eth0 {
|
|
|
|
AdvSendAdvert on;
|
|
|
|
prefix 2001:db8:1234:5678::/64 { };
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
The contents of the radvd configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.users.radvd =
|
2021-08-08 12:00:00 +00:00
|
|
|
{
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "radvd";
|
2014-06-27 06:45:04 +00:00
|
|
|
description = "Router Advertisement Daemon User";
|
|
|
|
};
|
2021-08-08 12:00:00 +00:00
|
|
|
users.groups.radvd = {};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2014-06-27 06:45:04 +00:00
|
|
|
systemd.services.radvd =
|
2011-02-19 19:19:55 +00:00
|
|
|
{ description = "IPv6 Router Advertisement Daemon";
|
2014-06-27 06:45:04 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig =
|
2024-05-02 04:09:52 +00:00
|
|
|
{ ExecStart = "@${cfg.package}/bin/radvd radvd -n -u radvd -d ${toString cfg.debugLevel} -C ${confFile}";
|
2014-06-27 06:45:04 +00:00
|
|
|
Restart = "always";
|
|
|
|
};
|
2011-02-19 19:19:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
|
|
|
}
|