2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.freeradius;
|
|
|
|
|
|
|
|
freeradiusService = cfg:
|
|
|
|
{
|
|
|
|
description = "FreeRadius server";
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
after = ["network.target"];
|
|
|
|
wants = ["network.target"];
|
|
|
|
preStart = ''
|
|
|
|
${pkgs.freeradius}/bin/radiusd -C -d ${cfg.configDir} -l stdout
|
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.freeradius}/bin/radiusd -f -d ${cfg.configDir} -l stdout" +
|
2024-09-19 14:19:46 +00:00
|
|
|
lib.optionalString cfg.debug " -xx";
|
2020-04-24 23:36:52 +00:00
|
|
|
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;
|
2021-12-19 01:06:50 +00:00
|
|
|
LogsDirectory = "radius";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
freeradiusConfig = {
|
2024-09-19 14:19:46 +00:00
|
|
|
enable = lib.mkEnableOption "the freeradius server";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
configDir = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "/etc/raddb";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
The path of the freeradius server configuration directory.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
debug = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Whether to enable debug logging for freeradius (-xx
|
|
|
|
option). This should not be left on, since it includes
|
|
|
|
sensitive data such as passwords in the logs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.freeradius = freeradiusConfig;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
config = lib.mkIf (cfg.enable) {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
users = {
|
|
|
|
users.radius = {
|
|
|
|
/*uid = config.ids.uids.radius;*/
|
|
|
|
description = "Radius daemon user";
|
2021-12-19 01:06:50 +00:00
|
|
|
isSystemUser = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.freeradius = freeradiusService cfg;
|
2024-09-19 14:19:46 +00:00
|
|
|
warnings = lib.optional cfg.debug "Freeradius debug logging is enabled. This will log passwords in plaintext to the journal!";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|