2018-07-20 21:54:05 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
2016-11-06 10:33:21 +01:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.leaps;
|
|
|
|
stateDir = "/var/lib/leaps/";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.leaps = {
|
2022-08-28 21:18:44 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc "leaps");
|
2016-11-06 10:33:21 +01:00
|
|
|
port = mkOption {
|
2021-06-18 17:29:44 +02:00
|
|
|
type = types.port;
|
2016-11-06 10:33:21 +01:00
|
|
|
default = 8080;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "A port where leaps listens for incoming http requests";
|
2016-11-06 10:33:21 +01:00
|
|
|
};
|
|
|
|
address = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
example = "127.0.0.1";
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Hostname or IP-address to listen to. By default it will listen on all interfaces.";
|
2016-11-06 10:33:21 +01:00
|
|
|
};
|
|
|
|
path = mkOption {
|
|
|
|
default = "/";
|
|
|
|
type = types.path;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Subdirectory used for reverse proxy setups";
|
2016-11-06 10:33:21 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users = {
|
|
|
|
users.leaps = {
|
|
|
|
uid = config.ids.uids.leaps;
|
|
|
|
description = "Leaps server user";
|
|
|
|
group = "leaps";
|
|
|
|
home = stateDir;
|
|
|
|
createHome = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
groups.leaps = {
|
|
|
|
gid = config.ids.gids.leaps;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.leaps = {
|
|
|
|
description = "leaps service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = "leaps";
|
|
|
|
Group = "leaps";
|
|
|
|
Restart = "on-failure";
|
|
|
|
WorkingDirectory = stateDir;
|
|
|
|
PrivateTmp = true;
|
2020-04-28 03:50:34 +02:00
|
|
|
ExecStart = "${pkgs.leaps}/bin/leaps -path ${toString cfg.path} -address ${cfg.address}:${toString cfg.port}";
|
2016-11-06 10:33:21 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|