2011-02-19 20:19:55 +01:00
|
|
|
# Module for the IPv6 Router Advertisement Daemon.
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2011-02-19 20:19:55 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2011-02-19 20:19:55 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.radvd;
|
|
|
|
|
|
|
|
confFile = pkgs.writeText "radvd.conf" cfg.config;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2022-06-30 20:35:53 +02:00
|
|
|
options.services.radvd = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2022-06-30 20:35:53 +02:00
|
|
|
enable = mkOption {
|
2020-04-20 20:05:26 +02:00
|
|
|
type = types.bool;
|
2011-02-19 20:19:55 +01:00
|
|
|
default = false;
|
|
|
|
description =
|
2022-07-28 23:19:15 +02:00
|
|
|
lib.mdDoc ''
|
2011-02-19 20:19:55 +01:00
|
|
|
Whether to enable the Router Advertisement Daemon
|
2022-07-28 23:19:15 +02:00
|
|
|
({command}`radvd`), which provides link-local
|
2011-02-19 20:19:55 +01: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 20:35:53 +02:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.radvd;
|
|
|
|
defaultText = literalExpression "pkgs.radvd";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-06-30 20:35:53 +02:00
|
|
|
The RADVD package to use for the RADVD service.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
2021-01-31 13:54:30 +01:00
|
|
|
type = types.lines;
|
2011-02-19 20:19:55 +01:00
|
|
|
example =
|
|
|
|
''
|
|
|
|
interface eth0 {
|
|
|
|
AdvSendAdvert on;
|
|
|
|
prefix 2001:db8:1234:5678::/64 { };
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
description =
|
2022-07-28 23:19:15 +02:00
|
|
|
lib.mdDoc ''
|
2011-02-19 20:19:55 +01:00
|
|
|
The contents of the radvd configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.radvd =
|
2021-08-08 14:00:00 +02:00
|
|
|
{
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "radvd";
|
2014-06-27 08:45:04 +02:00
|
|
|
description = "Router Advertisement Daemon User";
|
|
|
|
};
|
2021-08-08 14:00:00 +02:00
|
|
|
users.groups.radvd = {};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2014-06-27 08:45:04 +02:00
|
|
|
systemd.services.radvd =
|
2011-02-19 20:19:55 +01:00
|
|
|
{ description = "IPv6 Router Advertisement Daemon";
|
2014-06-27 08:45:04 +02:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig =
|
2022-06-30 20:35:53 +02:00
|
|
|
{ ExecStart = "@${cfg.package}/bin/radvd radvd -n -u radvd -C ${confFile}";
|
2014-06-27 08:45:04 +02:00
|
|
|
Restart = "always";
|
|
|
|
};
|
2011-02-19 20:19:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
|
|
|
}
|