about summary refs log tree commit diff
path: root/nixos/modules/services/networking/radvd.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules/services/networking/radvd.nix')
-rw-r--r--nixos/modules/services/networking/radvd.nix32
1 files changed, 20 insertions, 12 deletions
diff --git a/nixos/modules/services/networking/radvd.nix b/nixos/modules/services/networking/radvd.nix
index 08762c9c8372..0199502163a3 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" ];
+
+        after = [ "network.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
-          '';
+        path = [ pkgs.radvd ];
 
-        exec = "${pkgs.radvd}/sbin/radvd -m syslog -s -C ${confFile}";
+        preStart = ''
+          mkdir -m 755 -p /run/radvd
+          chown radvd /run/radvd
+        '';
 
-        daemonType = "fork";
+        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";
+          };
       };
 
   };