server-configuration/services/glauth.nix

66 lines
1.4 KiB
Nix
Raw Normal View History

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" { };
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 {
systemd.services.glauth = {
wantedBy = [];
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}'';
};
};
};
}