blob: 39f5bef14df8ab7225442d70948a3ce6840ba638 (
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
|
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.fcuny-net;
in
{
options.services.fcuny-net = {
enable = mkEnableOption "fcuny.net service";
package = mkPackageOption pkgs "fcuny.net" { };
port = mkOption {
type = types.port;
default = 8070;
description = "Port to listen on";
};
openFirewall = mkOption {
type = types.bool;
default = false;
description = "Whether to open the firewall for the goget service";
};
};
config = mkIf cfg.enable {
systemd.services.fcuny.net = {
description = "fcuny.net service";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
wants = [ "network.target" ];
serviceConfig = {
Type = "exec";
DynamicUser = true;
ExecStart = "${cfg.package}/bin/fcuny-net";
Restart = "always";
RestartSec = "5";
# Security settings
NoNewPrivileges = true;
ProtectSystem = "strict";
ProtectHome = true;
PrivateTmp = true;
ProtectKernelTunables = true;
ProtectKernelModules = true;
ProtectControlGroups = true;
RestrictSUIDSGID = true;
RestrictRealtime = true;
RestrictNamespaces = true;
LockPersonality = true;
MemoryDenyWriteExecute = true;
};
};
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.port ];
};
};
}
|