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 =
|
2022-07-28 21:19:15 +00:00
|
|
|
lib.mdDoc ''
|
2011-02-19 19:19:55 +00:00
|
|
|
Whether to enable the Router Advertisement Daemon
|
2022-07-28 21:19:15 +00:00
|
|
|
({command}`radvd`), which provides link-local
|
2011-02-19 19:19:55 +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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-06-30 18:35:53 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.radvd;
|
|
|
|
defaultText = literalExpression "pkgs.radvd";
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-06-30 18:35:53 +00:00
|
|
|
The RADVD package to use for the RADVD service.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
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 =
|
2022-07-28 21:19:15 +00:00
|
|
|
lib.mdDoc ''
|
2011-02-19 19:19:55 +00:00
|
|
|
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 =
|
2022-06-30 18:35:53 +00:00
|
|
|
{ ExecStart = "@${cfg.package}/bin/radvd radvd -n -u radvd -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
|
|
|
|
|
|
|
}
|