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