53 lines
1.1 KiB
Nix
53 lines
1.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}: let
|
|
cfg = config.services.keikos.web;
|
|
in {
|
|
options.services.keikos.web = with lib;
|
|
with lib.types; {
|
|
enable = mkEnableOption "";
|
|
port = mkOption {
|
|
type = port;
|
|
default = 7331;
|
|
};
|
|
package = mkOption {
|
|
type = package;
|
|
default = config._keikos-flake.pkg;
|
|
};
|
|
user = mkOption {
|
|
type = str;
|
|
default = "keikoswork";
|
|
};
|
|
group = mkOption {
|
|
type = str;
|
|
default = "keikoswork";
|
|
};
|
|
envFile = mkOption {
|
|
type = path;
|
|
};
|
|
};
|
|
config = with lib;
|
|
mkIf cfg.enable {
|
|
systemd.services."keikoswork" = {
|
|
after = ["network.target"];
|
|
wantedBy = ["multi-user.target"];
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
User = cfg.user;
|
|
Group = cfg.group;
|
|
ExecStart = "${lib.escapeShellArg (lib.getExe cfg.package)} web -port ${toString cfg.port}";
|
|
Restart = "on-success";
|
|
EnvironmentFile = cfg.envFile;
|
|
};
|
|
};
|
|
|
|
users.users."${cfg.user}" = {
|
|
isSystemUser = true;
|
|
group = cfg.group;
|
|
};
|
|
users.groups."${cfg.group}" = {};
|
|
};
|
|
}
|