about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoachim F <joachifm@users.noreply.github.com>2018-02-17 09:17:35 +0000
committerGitHub <noreply@github.com>2018-02-17 09:17:35 +0000
commit71a32c36fed7ce9a006329bcd45a29311d6a05b3 (patch)
tree281f8974a551239996a6e78cc07b3f14a7245cbf
parentf010a682608176e96f6ec4ac1cc8536a00a90bbc (diff)
parent2a2e885cd0cdb2ee1a1b1b37b3e33d58a935b462 (diff)
downloadnixlib-71a32c36fed7ce9a006329bcd45a29311d6a05b3.tar
nixlib-71a32c36fed7ce9a006329bcd45a29311d6a05b3.tar.gz
nixlib-71a32c36fed7ce9a006329bcd45a29311d6a05b3.tar.bz2
nixlib-71a32c36fed7ce9a006329bcd45a29311d6a05b3.tar.lz
nixlib-71a32c36fed7ce9a006329bcd45a29311d6a05b3.tar.xz
nixlib-71a32c36fed7ce9a006329bcd45a29311d6a05b3.tar.zst
nixlib-71a32c36fed7ce9a006329bcd45a29311d6a05b3.zip
Merge pull request #34587 from netixx/add-freeradius-service
nixos/freeradius : init - Added freeradius service
-rw-r--r--nixos/modules/services/networking/freeradius.nix72
1 files changed, 72 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/freeradius.nix b/nixos/modules/services/networking/freeradius.nix
new file mode 100644
index 000000000000..45cba1ce2770
--- /dev/null
+++ b/nixos/modules/services/networking/freeradius.nix
@@ -0,0 +1,72 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+  cfg = config.services.freeradius;
+
+  freeradiusService = cfg:
+  {
+    description = "FreeRadius server";
+    wantedBy = ["multi-user.target"];
+    after = ["network-online.target"];
+    wants = ["network-online.target"];
+    preStart = ''
+      ${pkgs.freeradius}/bin/radiusd -C -d ${cfg.configDir} -l stdout
+    '';
+
+    serviceConfig = {
+        ExecStart = "${pkgs.freeradius}/bin/radiusd -f -d ${cfg.configDir} -l stdout -xx";
+        ExecReload = [
+          "${pkgs.freeradius}/bin/radiusd -C -d ${cfg.configDir} -l stdout"
+          "${pkgs.coreutils}/bin/kill -HUP $MAINPID"
+        ];
+        User = "radius";
+        ProtectSystem = "full";
+        ProtectHome = "on";
+        Restart = "on-failure";
+        RestartSec = 2;
+    };
+  };
+
+  freeradiusConfig = {
+    enable = mkEnableOption "the freeradius server";
+
+    configDir = mkOption {
+      type = types.path;
+      default = "/etc/raddb";
+      description = ''
+        The path of the freeradius server configuration directory.
+      '';
+    };
+
+  };
+
+in
+
+{
+
+  ###### interface
+
+  options = {
+    services.freeradius = freeradiusConfig;
+  };
+
+
+  ###### implementation
+
+  config = mkIf (cfg.enable) {
+
+    users = {
+      extraUsers.radius = {
+        /*uid = config.ids.uids.radius;*/
+        description = "Radius daemon user";
+      };
+    };
+
+    systemd.services.freeradius = freeradiusService cfg;
+
+  };
+
+}