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