main
nix 69 lines 2.68 KB
Raw
1 { config, pkgs, ... }:
2
3 {
4 systemd.services.ofborg-github-comment-poster = {
5 description = "ofBorg GitHub comment poster";
6
7 wantedBy = [ "ofborg.target" ];
8 bindsTo = [ "ofborg.target" ];
9 restartTriggers = [ config.environment.etc."ofborg.json".source ];
10
11 stopIfChanged = false;
12 unitConfig.StartLimitIntervalSec = 0;
13 serviceConfig = {
14 # Filesystem stuff
15 ProtectSystem = "strict"; # Prevent writing to most of /
16 ProtectHome = true; # Prevent accessing /home and /root
17 PrivateTmp = true; # Give an own directory under /tmp
18 PrivateDevices = true; # Deny access to most of /dev
19 ProtectKernelTunables = true; # Protect some parts of /sys
20 ProtectControlGroups = true; # Remount cgroups read-only
21 RestrictSUIDSGID = true; # Prevent creating SETUID/SETGID files
22 PrivateMounts = true; # Give an own mount namespace
23 RemoveIPC = true;
24 UMask = "0077";
25
26 Restart = "always";
27 RestartSec = "5s";
28 ExecStart = "${pkgs.ofborg}/bin/github-comment-poster /etc/ofborg.json";
29 User = "ofborg-github-comment-poster";
30 Group = "ofborg-github-comment-poster";
31 SupplementaryGroups = [ "ofborg-github-app-key" ];
32
33 # Capabilities
34 CapabilityBoundingSet = ""; # Allow no capabilities at all
35 NoNewPrivileges = true; # Disallow getting more capabilities. This is also implied by other options.
36
37 # Kernel stuff
38 ProtectKernelModules = true; # Prevent loading of kernel modules
39 SystemCallArchitectures = "native"; # Usually no need to disable this
40 ProtectKernelLogs = true; # Prevent access to kernel logs
41 ProtectClock = true; # Prevent setting the RTC
42
43 # Misc
44 LockPersonality = true; # Prevent change of the personality
45 ProtectHostname = true; # Give an own UTS namespace
46 RestrictRealtime = true; # Prevent switching to RT scheduling
47 MemoryDenyWriteExecute = true; # Maybe disable this for interpreters like python
48 PrivateUsers = true; # If anything randomly breaks, it's mostly because of this
49 RestrictNamespaces = true;
50 SystemCallFilter = "@system-service";
51 };
52 };
53
54 users.users.ofborg-github-comment-poster = {
55 isSystemUser = true;
56 group = "ofborg-github-comment-poster";
57 description = "ofBorg GitHub comment poster system user";
58 };
59 users.groups.ofborg-github-comment-poster = { };
60
61 sops.secrets = {
62 "ofborg/github-comment-poster-rabbitmq-password" = {
63 owner = "ofborg-github-comment-poster";
64 restartUnits = [ "ofborg-github-comment-poster.service" ];
65 sopsFile = ../../secrets/ofborg.core01.ofborg.org.yml;
66 };
67 "ofborg/github-app-key".restartUnits = [ "ofborg-github-comment-poster.service" ];
68 };
69 }