diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 98f1b52aba4..99a33f68735 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -146,6 +146,7 @@ neo4j = 136; riemann = 137; riemanndash = 138; + radvd = 139; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! diff --git a/nixos/modules/services/networking/radvd.nix b/nixos/modules/services/networking/radvd.nix index 08762c9c837..0199502163a 100644 --- a/nixos/modules/services/networking/radvd.nix +++ b/nixos/modules/services/networking/radvd.nix @@ -52,24 +52,32 @@ in config = mkIf cfg.enable { - environment.systemPackages = [ pkgs.radvd ]; + users.extraUsers.radvd = + { uid = config.ids.uids.radvd; + description = "Router Advertisement Daemon User"; + }; - jobs.radvd = + systemd.services.radvd = { description = "IPv6 Router Advertisement Daemon"; - startOn = "started network-interfaces"; + wantedBy = [ "multi-user.target" ]; - preStart = - '' - # !!! Radvd only works if IPv6 forwarding is enabled. But - # this should probably be done somewhere else (and not - # necessarily for all interfaces). - echo 1 > /proc/sys/net/ipv6/conf/all/forwarding - ''; + after = [ "network.target" ]; - exec = "${pkgs.radvd}/sbin/radvd -m syslog -s -C ${confFile}"; + path = [ pkgs.radvd ]; - daemonType = "fork"; + preStart = '' + mkdir -m 755 -p /run/radvd + chown radvd /run/radvd + ''; + + serviceConfig = + { ExecStart = "@${pkgs.radvd}/sbin/radvd radvd" + + " -p /run/radvd/radvd.pid -m syslog -u radvd -C ${confFile}"; + Restart = "always"; + Type = "forking"; + PIDFile = "/run/radvd/radvd.pid"; + }; }; };