2024-03-26 20:19:40 -06:00
|
|
|
{ lib, config, pkgs, ... }:
|
|
|
|
let cfg = config.services.kogs;
|
|
|
|
in {
|
|
|
|
options = with lib; {
|
|
|
|
services.kogs = {
|
|
|
|
enable = lib.mkEnableOption "Enable kogs";
|
|
|
|
|
|
|
|
listen = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = ":8383";
|
|
|
|
description = ''
|
|
|
|
Listen string
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = with types; oneOf [ str int ];
|
|
|
|
default = "kogs";
|
|
|
|
description = ''
|
|
|
|
The user the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = with types; oneOf [ str int ];
|
|
|
|
default = "kogs";
|
|
|
|
description = ''
|
|
|
|
The group the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
registration = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Allow new users to register
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
2024-03-31 13:43:35 -06:00
|
|
|
default = "/var/lib/kogs/";
|
|
|
|
description = "Path kogs will use to store the database";
|
|
|
|
};
|
|
|
|
|
|
|
|
dbDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "${cfg.dataDir}/db";
|
|
|
|
description = "Path kogs will use to store the database files";
|
2024-03-26 20:19:40 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.kogs;
|
|
|
|
defaultText = literalExpression "pkgs.kogs";
|
|
|
|
description = "The package to use for kogs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf (cfg.enable) {
|
|
|
|
users.groups.${cfg.group} = { };
|
|
|
|
users.users.${cfg.user} = {
|
|
|
|
description = "kogs service user";
|
|
|
|
isSystemUser = true;
|
|
|
|
home = "${cfg.dataDir}";
|
|
|
|
createHome = true;
|
|
|
|
group = "${cfg.group}";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.kogs = {
|
|
|
|
enable = true;
|
|
|
|
description = "kogs server";
|
|
|
|
wantedBy = [ "network-online.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
|
|
|
|
|
|
|
environment = { HOME = "${cfg.dataDir}"; };
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
|
2024-03-31 13:55:13 -06:00
|
|
|
Restart = "always";
|
|
|
|
|
2024-03-26 20:19:40 -06:00
|
|
|
ExecStart = ''
|
2024-03-31 13:43:35 -06:00
|
|
|
${cfg.package}/bin/kogs -listen ${cfg.listen} -db ${cfg.dbDir} ${lib.optionalString (cfg.registration == false) "-reg=false"}
|
2024-03-26 20:19:40 -06:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|