about summary refs log tree commit diff
path: root/modules/services/gerrit/default.nix
blob: 3d0e3df336b9336dfa3162336dde8f377834717d (plain) (blame)
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
42
43
44
45
46
47
48
49
50
{ config, pkgs, lib, ... }:
let cfg = config.my.services.gerrit;
in {
  options.my.services.gerrit = with lib; {
    enable = mkEnableOption "gerrit git server";
    vhostName = mkOption {
      type = types.str;
      example = "cl.fcuny.net";
      description = "Name for the virtual host";
    };
  };

  config = lib.mkIf cfg.enable {
    services.gerrit = {
      enable = true;
      listenAddress = "[::]:4778";
      builtinPlugins = [ "download-commands" "hooks" ];
      jvmHeapLimit = "4g";

      settings = {
        core.packedGitLimit = "100m";
        log.jsonLogging = true;
        log.textLogging = false;
        sshd.advertisedAddress = "git.fcuny.net:29418";
        cache.web_sessions.maxAge = "3 months";
        plugins.allowRemoteAdmin = false;
        change.enableAttentionSet = true;
        change.enableAssignee = false;

        gerrit = {
          canonicalWebUrl = "https://${cfg.vhostName}";
          docUrl = "/Documentation";
        };

        httpd.listenUrl = "proxy-https://${cfg.listenAddress}";

        download.command = [ "checkout" "cherry_pick" "format_patch" "pull" ];

        # Receiving email is not currently supported.
        sendemail = { enable = false; };
      };
    };

    services.nginx.virtualHosts."${cfg.vhostName}}" = {
      forceSSL = true;
      enableACME = true;
      locations."/" = { proxyPass = "http://127.0.0.1:4778"; };
    };
  };
}