blob: 213f4ef046483a820cdae15d6425444f05acff73 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
{ config, lib, pkgs, utils, ... }:
let
cfg = config.services.flood;
in
{
meta.maintainers = with lib.maintainers; [ thiagokokada ];
options.services.flood = {
enable = lib.mkEnableOption "flood";
package = lib.mkPackageOption pkgs "flood" { };
openFirewall = lib.mkEnableOption "" // {
description = "Whether to open the firewall for the port in {option}`services.flood.port`.";
};
port = lib.mkOption {
type = lib.types.int;
description = "Port to bind webserver.";
default = 3000;
example = 3001;
};
host = lib.mkOption {
type = lib.types.str;
description = "Host to bind webserver.";
default = "localhost";
example = "::";
};
extraArgs = lib.mkOption {
type = with lib.types; listOf str;
description = "Extra arguments passed to `flood`.";
default = [ ];
example = [ "--baseuri=/" ];
};
};
config = lib.mkIf cfg.enable {
systemd.services.flood = {
description = "A modern web UI for various torrent clients.";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
unitConfig = {
Documentation = "https://github.com/jesec/flood/wiki";
};
serviceConfig = {
Restart = "on-failure";
RestartSec = "3s";
ExecStart = utils.escapeSystemdExecArgs ([
(lib.getExe cfg.package)
"--host"
cfg.host
"--port"
(toString cfg.port)
"--rundir=/var/lib/flood"
] ++ cfg.extraArgs);
CapabilityBoundingSet = [ "" ];
DynamicUser = true;
LockPersonality = true;
NoNewPrivileges = true;
PrivateDevices = true;
PrivateTmp = true;
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
ProtectSystem = "strict";
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" ];
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
StateDirectory = "flood";
SystemCallArchitectures = "native";
SystemCallFilter = [ "@system-service" "@pkey" "~@privileged" ];
};
};
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [
cfg.port
];
};
}
|