summary refs log tree commit diff
path: root/fleet/hosts/kaikou/gerrit.nix
blob: 5308ad451ca4d657d87e1dddb9290987ada7549e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# SPDX-FileCopyrightText: V <v@unfathomable.blue>
# SPDX-License-Identifier: OSL-3.0

{ pkgs, ... }:

{
  services.gerrit = {
    enable = true;
    serverId = "f1c53737-3ce4-4b28-9e99-825cacff1cf8";

    # Here we'd set listenAddress to a UNIX socket path, except
    # Gerrit for some reason does not support listening on them.
    # TODO(V): Figure out why.

    plugins = [
      pkgs.gerrit-oauth-provider
    ];

    settings = {
      # Proxy through Caddy.
      httpd.listenUrl = "proxy-https://[::]:8080/";
      gerrit.canonicalWebUrl = "https://review.unfathomable.blue/";

      # Authenticate with Google.
      auth.type = "OAUTH";
      auth.gitBasicAuthPolicy = "HTTP";
      plugin.gerrit-oauth-provider-google-oauth = {
        client-id = "196183758720-sjo2ekbchb0ki24gn58g6grbdrj3uoqh.apps.googleusercontent.com";
        # client-secret is set in /var/lib/gerrit/etc/secure.config.
        use-email-as-username = true;
      };
    };
  };

  services.caddy.extraConfig = ''
    review.unfathomable.blue {
      import common
      reverse_proxy localhost:8080
    }
  '';
}