at 23.11-pre 1.9 kB view raw
1# Module for the IPv6 Router Advertisement Daemon. 2 3{ config, lib, pkgs, ... }: 4 5with lib; 6 7let 8 9 cfg = config.services.radvd; 10 11 confFile = pkgs.writeText "radvd.conf" cfg.config; 12 13in 14 15{ 16 17 ###### interface 18 19 options.services.radvd = { 20 21 enable = mkOption { 22 type = types.bool; 23 default = false; 24 description = 25 lib.mdDoc '' 26 Whether to enable the Router Advertisement Daemon 27 ({command}`radvd`), which provides link-local 28 advertisements of IPv6 router addresses and prefixes using 29 the Neighbor Discovery Protocol (NDP). This enables 30 stateless address autoconfiguration in IPv6 clients on the 31 network. 32 ''; 33 }; 34 35 package = mkOption { 36 type = types.package; 37 default = pkgs.radvd; 38 defaultText = literalExpression "pkgs.radvd"; 39 description = lib.mdDoc '' 40 The RADVD package to use for the RADVD service. 41 ''; 42 }; 43 44 config = mkOption { 45 type = types.lines; 46 example = 47 '' 48 interface eth0 { 49 AdvSendAdvert on; 50 prefix 2001:db8:1234:5678::/64 { }; 51 }; 52 ''; 53 description = 54 lib.mdDoc '' 55 The contents of the radvd configuration file. 56 ''; 57 }; 58 59 }; 60 61 62 ###### implementation 63 64 config = mkIf cfg.enable { 65 66 users.users.radvd = 67 { 68 isSystemUser = true; 69 group = "radvd"; 70 description = "Router Advertisement Daemon User"; 71 }; 72 users.groups.radvd = {}; 73 74 systemd.services.radvd = 75 { description = "IPv6 Router Advertisement Daemon"; 76 wantedBy = [ "multi-user.target" ]; 77 after = [ "network.target" ]; 78 serviceConfig = 79 { ExecStart = "@${cfg.package}/bin/radvd radvd -n -u radvd -C ${confFile}"; 80 Restart = "always"; 81 }; 82 }; 83 84 }; 85 86}