|
| 1 | +{ |
| 2 | + lib, |
| 3 | + config, |
| 4 | + ... |
| 5 | +}: let |
| 6 | + cfg = config.services.demostf.sync; |
| 7 | +in { |
| 8 | + options = { |
| 9 | + services.demostf.sync = with lib; { |
| 10 | + enable = mkEnableOption "demostf sync"; |
| 11 | + package = mkOption { |
| 12 | + type = types.package; |
| 13 | + defaultText = literalExpression "pkgs.demostf-sync"; |
| 14 | + description = "package to use"; |
| 15 | + }; |
| 16 | + socket = mkOption { |
| 17 | + type = types.str; |
| 18 | + default = "/var/run/demostf-sync/sync.socket"; |
| 19 | + }; |
| 20 | + }; |
| 21 | + }; |
| 22 | + |
| 23 | + config = lib.mkIf cfg.enable { |
| 24 | + systemd.services.demostf-sync = { |
| 25 | + wantedBy = ["multi-user.target"]; |
| 26 | + environment = { |
| 27 | + SOCKET = cfg.socket; |
| 28 | + }; |
| 29 | + |
| 30 | + serviceConfig = { |
| 31 | + DynamicUser = true; |
| 32 | + ExecStart = "${cfg.package}/bin/sync"; |
| 33 | + Restart = "on-failure"; |
| 34 | + |
| 35 | + PrivateTmp = true; |
| 36 | + PrivateUsers = true; |
| 37 | + ProtectSystem = "strict"; |
| 38 | + ProtectHome = true; |
| 39 | + NoNewPrivileges = true; |
| 40 | + PrivateDevices = true; |
| 41 | + ProtectClock = true; |
| 42 | + CapabilityBoundingSet = true; |
| 43 | + ProtectKernelLogs = true; |
| 44 | + ProtectControlGroups = true; |
| 45 | + SystemCallArchitectures = "native"; |
| 46 | + ProtectKernelModules = true; |
| 47 | + RestrictNamespaces = true; |
| 48 | + MemoryDenyWriteExecute = true; |
| 49 | + ProtectHostname = true; |
| 50 | + LockPersonality = true; |
| 51 | + ProtectKernelTunables = true; |
| 52 | + DevicePolicy = "closed"; |
| 53 | + RestrictAddressFamilies = ["AF_UNIX"]; |
| 54 | + RestrictRealtime = true; |
| 55 | + ProcSubset = "pid"; |
| 56 | + ProtectProc = "invisible"; |
| 57 | + SystemCallFilter = ["@system-service" "~@resources" "~@privileged"]; |
| 58 | + UMask = "0007"; |
| 59 | + IPAddressDeny = "any"; |
| 60 | + RuntimeDirectory = "demostf-sync"; |
| 61 | + }; |
| 62 | + }; |
| 63 | + }; |
| 64 | +} |
0 commit comments