blob: 1551f5508d93d65a2bd63de1eb1baf845cbd45d9 (
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
|
{ pkgs, lib, config, ... }:
let
cfg = config.vuizvui.services.drawpile;
port = 27750;
adminPort = 9876;
stateDir = "/var/lib/drawpile";
in {
options = {
vuizvui.services.drawpile = {
enable = lib.mkEnableOption "drawpile dedicated server";
configFile = lib.mkOption {
type = lib.types.str;
description = ''
The ini configuration file of the server.
See https://drawpile.net/help/server/
'';
};
};
};
config = lib.mkIf cfg.enable {
systemd.services.drawpile = {
description = "drawpile headless server";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
Restart = "always";
RestartSec = "1s";
KillSignal = "SIGINT";
DynamicUser = true;
StateDirectory = "drawpile";
UMask = "0007";
ExecStart = toString [
"${pkgs.drawpile-server-headless}/bin/drawpile-srv"
"--config" (pkgs.writeText "drawpile-server.ini" cfg.configFile)
# implicit from StateDirectory
"--sessions" "/var/lib/drawpile"
"--port" (toString port)
"--web-admin-port" (toString adminPort)
];
# Sandboxing
NoNewPrivileges = true;
PrivateTmp = true;
PrivateDevices = true;
ProtectSystem = "strict";
ProtectHome = true;
ProtectControlGroups = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
RestrictAddressFamilies = [ "AF_UNIX" "AF_INET" "AF_INET6" "AF_NETLINK" ];
RestrictRealtime = true;
RestrictNamespaces = true;
MemoryDenyWriteExecute = true;
};
};
networking.firewall.allowedTCPPorts = [ port ];
};
}
|