From aa77fe0fb0f2b6636a57fd2ced4afd6636b4c1e1 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Fri, 27 Jun 2014 01:45:04 -0500 Subject: [PATCH] nixos/radvd: Convert to a systemd unit Additionally, remove the automatic initialization of the ipv6 forwarding sysctl as this should be handled by the end user. This really should not be an issue as most people running radvd are likely forwarding ipv6 packets. --- nixos/modules/misc/ids.nix | 1 + nixos/modules/services/networking/radvd.nix | 32 +++++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) 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"; + }; }; };