84 lines
1.9 KiB
Nix
84 lines
1.9 KiB
Nix
{ 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;
|
|
default = "/var/lib/kogs";
|
|
description = "Path kogs will use to store the sqlite database";
|
|
};
|
|
|
|
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;
|
|
|
|
ExecStart = ''
|
|
${cfg.package}/bin/kogs -listen ${cfg.listen} ${lib.optionalString (!cfg.registration) "-reg=false"}
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|