Unverified Commit 386a1d5d authored by Tomodachi94's avatar Tomodachi94
Browse files

nixos/hydra: add system-hydra.slice

Part of #279915
parent 70b35a2d
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -311,6 +311,11 @@ in
      )
    ];

    systemd.slices.system-hydra = {
      description = "Hydra Slice";
      documentation = [ "file://${cfg.package}/share/doc/hydra/index.html" "https://nixos.org/hydra/manual/" ];
    };

    systemd.services.hydra-init =
      { wantedBy = [ "multi-user.target" ];
        requires = lib.optional haveLocalDB "postgresql.service";
@@ -371,6 +376,7 @@ in
        serviceConfig.User = "hydra";
        serviceConfig.Type = "oneshot";
        serviceConfig.RemainAfterExit = true;
        serviceConfig.Slice = "system-hydra.slice";
      };

    systemd.services.hydra-server =
@@ -389,6 +395,7 @@ in
            User = "hydra-www";
            PermissionsStartOnly = true;
            Restart = "always";
            Slice = "system-hydra.slice";
          };
      };

@@ -408,6 +415,7 @@ in
            ExecStopPost = "${hydra-package}/bin/hydra-queue-runner --unlock";
            User = "hydra-queue-runner";
            Restart = "always";
            Slice = "system-hydra.slice";

            # Ensure we can get core dumps.
            LimitCORE = "infinity";
@@ -430,6 +438,7 @@ in
            User = "hydra";
            Restart = "always";
            WorkingDirectory = baseDir;
            Slice = "system-hydra.slice";
          };
      };

@@ -442,6 +451,7 @@ in
        serviceConfig =
          { ExecStart = "@${hydra-package}/bin/hydra-update-gc-roots hydra-update-gc-roots";
            User = "hydra";
            Slice = "system-hydra.slice";
          };
        startAt = "2,14:15";
      };
@@ -455,6 +465,7 @@ in
        serviceConfig =
          { ExecStart = "@${hydra-package}/bin/hydra-send-stats hydra-send-stats";
            User = "hydra";
            Slice = "system-hydra.slice";
          };
      };

@@ -474,6 +485,7 @@ in
            User = "hydra-queue-runner";
            Restart = "always";
            RestartSec = 5;
            Slice = "system-hydra.slice";
          };
      };

@@ -492,6 +504,7 @@ in
            fi
          '';
        startAt = "*:0/5";
        serviceConfig.Slice = "system-hydra.slice";
      };

    # Periodically compress build logs. The queue runner compresses
@@ -509,6 +522,7 @@ in
            find ${baseDir}/build-logs -type f -name "*.drv" -mtime +3 -size +0c | xargs -r $compression --force --quiet
          '';
        startAt = "Sun 01:45";
        serviceConfig.Slice = "system-hydra.slice";
      };

    services.postgresql.enable = lib.mkIf haveLocalDB true;