2024-01-07 13:43:00 -07:00
|
|
|
{config, pkgs, lib, ...}:
|
|
|
|
let
|
|
|
|
cfg = config.services.glauth;
|
|
|
|
settingsFormat = pkgs.formats.toml {};
|
|
|
|
in
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.glauth = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = with types; bool;
|
|
|
|
description = ''
|
|
|
|
Enable the glauth system service
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkPackageOption pkgs "glauth" { };
|
|
|
|
|
2024-01-10 00:48:59 -07:00
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/glauth";
|
|
|
|
};
|
|
|
|
|
2024-01-07 13:43:00 -07:00
|
|
|
user = mkOption {
|
|
|
|
default = "glauth";
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Name of the user.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
default = "glauth";
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Name of the group.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = settingsFormat.type;
|
|
|
|
default = {};
|
|
|
|
description = ''
|
|
|
|
Configuration for glauth.cfg, see
|
|
|
|
<link xlink:href="https://github.com/glauth/glauth/blob/master/v2/sample-simple.cfg"
|
|
|
|
for supported settings.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-01-07 13:57:37 -07:00
|
|
|
# Add user for glauth
|
|
|
|
users.users."${cfg.user}" = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = cfg.group;
|
2024-01-10 00:48:59 -07:00
|
|
|
home = cfg.dataDir;
|
2024-01-07 13:57:37 -07:00
|
|
|
};
|
|
|
|
users.groups."${cfg.group}" = {};
|
|
|
|
|
|
|
|
# Add systemd service
|
2024-01-07 13:43:00 -07:00
|
|
|
systemd.services.glauth = {
|
2024-01-07 13:51:33 -07:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2024-01-07 13:43:00 -07:00
|
|
|
after = [ "network.target" ];
|
|
|
|
description = "Start a glauth server.";
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "exec";
|
|
|
|
User = "${cfg.user}";
|
|
|
|
Group = "${cfg.group}";
|
|
|
|
ExecStart = ''${cfg.package}/bin/glauth -c ${settingsFormat.generate "glauth.cfg" cfg.settings}'';
|
2024-01-10 00:48:59 -07:00
|
|
|
StateDirectory = mkIf (cfg.dataDir == "/var/lib/glauth") [ "glauth" ];
|
2024-01-07 13:43:00 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|