blob: 731b1e1f2c4d41b9c3abbd256582248e2bd790fb (
plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.geph;
in
{
options.services.geph = {
enable = lib.mkEnableOption "geph client daemon";
package = lib.mkPackageOption pkgs "geph" { };
configFile = lib.mkOption {
type = lib.types.pathWith {
inStore = false;
absolute = true;
};
description = ''
Path to the geph config file.
This file contain sensitive credentials, so it must not live in the Nix store.
'';
};
};
config = lib.mkIf cfg.enable {
boot.kernelModules = [ "tun" ];
networking.firewall.checkReversePath = "loose";
systemd.services.geph = {
description = "geph client daemon";
wantedBy = [ "multi-user.target" ];
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
startLimitBurst = 5;
startLimitIntervalSec = 20;
serviceConfig = {
DynamicUser = true;
LoadCredential = "geph-config:${cfg.configFile}";
ExecStart = "${lib.getExe cfg.package} --config %d/geph-config";
Restart = "on-failure";
RestartSec = 2;
LimitNOFILE = 65535;
StateDirectory = "geph";
StateDirectoryMode = "0700";
WorkingDirectory = "/var/lib/geph";
AmbientCapabilities = [
"CAP_NET_ADMIN"
"CAP_NET_BIND_SERVICE"
];
CapabilityBoundingSet = [
"CAP_NET_ADMIN"
"CAP_NET_BIND_SERVICE"
];
DeviceAllow = "/dev/net/tun rw";
DevicePolicy = "closed";
PrivateUsers = false;
PrivateDevices = false;
RestrictAddressFamilies = [
"AF_UNIX"
"AF_INET"
"AF_INET6"
"AF_NETLINK"
];
LockPersonality = true;
MemoryDenyWriteExecute = true;
NoNewPrivileges = true;
PrivateMounts = true;
PrivateTmp = true;
ProcSubset = "pid";
ProtectClock = true;
ProtectControlGroups = true;
ProtectHome = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
ProtectSystem = "strict";
RestrictNamespaces = true;
RestrictRealtime = true;
RestrictSUIDSGID = true;
SystemCallArchitectures = "native";
SystemCallFilter = "@system-service";
UMask = "0077";
};
};
};
meta = {
maintainers = with lib.maintainers; [
MCSeekeri
];
};
}
|