2020-06-07 20:30:52 +02:00
|
|
|
# Gerrit configuration for the TVL monorepo
|
2021-04-02 14:18:50 +02:00
|
|
|
{ depot, pkgs, config, lib, ... }:
|
2020-06-07 20:30:52 +02:00
|
|
|
|
2020-06-13 07:02:19 +02:00
|
|
|
let
|
|
|
|
cfg = config.services.gerrit;
|
|
|
|
gerritHooks = pkgs.runCommandNoCC "gerrit-hooks" {} ''
|
2020-06-13 07:11:38 +02:00
|
|
|
mkdir -p $out
|
2021-04-02 14:18:50 +02:00
|
|
|
ln -s ${depot.ops.besadii}/bin/besadii $out/ref-updated
|
2020-06-13 07:02:19 +02:00
|
|
|
'';
|
2020-06-11 00:40:34 +02:00
|
|
|
in {
|
2020-06-07 20:30:52 +02:00
|
|
|
services.gerrit = {
|
|
|
|
enable = true;
|
|
|
|
listenAddress = "[::]:4778"; # 4778 - grrt
|
|
|
|
serverId = "4fdfa107-4df9-4596-8e0a-1d2bbdd96e36";
|
2020-06-13 07:02:19 +02:00
|
|
|
builtinPlugins = [
|
|
|
|
"download-commands"
|
|
|
|
"hooks"
|
|
|
|
];
|
2020-06-13 04:32:46 +02:00
|
|
|
|
2021-04-02 14:18:50 +02:00
|
|
|
plugins = with depot.third_party.gerrit_plugins; [
|
2020-06-13 20:30:48 +02:00
|
|
|
owners
|
2021-04-03 17:54:42 +02:00
|
|
|
oauth
|
2021-04-06 18:47:48 +02:00
|
|
|
depot.ops.gerrit-tvl
|
2020-06-13 20:30:48 +02:00
|
|
|
];
|
|
|
|
|
2021-04-02 14:18:50 +02:00
|
|
|
package = depot.third_party.gerrit;
|
2020-06-14 19:58:53 +02:00
|
|
|
|
2020-07-11 02:35:00 +02:00
|
|
|
jvmHeapLimit = "4g";
|
|
|
|
|
2021-08-12 14:35:37 +02:00
|
|
|
# In some NixOS channel bump, the default version of OpenJDK has
|
|
|
|
# changed to one that is incompatible with our current version of
|
|
|
|
# Gerrit.
|
|
|
|
#
|
|
|
|
# TODO(tazjin): Update Gerrit and remove this when possible.
|
|
|
|
jvmPackage = pkgs.openjdk11_headless;
|
|
|
|
|
2020-06-07 20:30:52 +02:00
|
|
|
settings = {
|
|
|
|
core.packedGitLimit = "100m";
|
|
|
|
log.jsonLogging = true;
|
|
|
|
log.textLogging = false;
|
2020-06-13 04:31:17 +02:00
|
|
|
sshd.advertisedAddress = "code.tvl.fyi:29418";
|
2020-06-13 07:02:19 +02:00
|
|
|
hooks.path = "${gerritHooks}";
|
2020-06-16 19:28:36 +02:00
|
|
|
cache.web_sessions.maxAge = "3 months";
|
2020-07-25 22:18:10 +02:00
|
|
|
plugins.allowRemoteAdmin = false;
|
|
|
|
change.enableAttentionSet = true;
|
|
|
|
change.enableAssignee = false;
|
2020-06-11 00:40:34 +02:00
|
|
|
|
|
|
|
# Configures gerrit for being reverse-proxied by nginx as per
|
|
|
|
# https://gerrit-review.googlesource.com/Documentation/config-reverseproxy.html
|
2020-07-11 02:13:03 +02:00
|
|
|
gerrit = {
|
|
|
|
canonicalWebUrl = "https://cl.tvl.fyi";
|
|
|
|
docUrl = "/Documentation";
|
|
|
|
};
|
|
|
|
|
2020-06-11 00:40:34 +02:00
|
|
|
httpd.listenUrl = "proxy-https://${cfg.listenAddress}";
|
2020-06-08 02:35:45 +02:00
|
|
|
|
2020-06-13 04:32:46 +02:00
|
|
|
download.command = [
|
|
|
|
"checkout"
|
|
|
|
"cherry_pick"
|
|
|
|
"format_patch"
|
|
|
|
"pull"
|
|
|
|
];
|
|
|
|
|
2021-03-31 23:21:29 +02:00
|
|
|
# Configure for cgit.
|
2020-06-11 23:49:37 +02:00
|
|
|
gitweb = {
|
|
|
|
type = "custom";
|
2021-03-31 23:21:29 +02:00
|
|
|
url = "https://code.tvl.fyi";
|
|
|
|
project = "/";
|
|
|
|
revision = "/commit/?id=\${commit}";
|
|
|
|
branch = "/log/?h=\${branch}";
|
|
|
|
tag = "/tag/?h=\${tag}";
|
|
|
|
roottree = "/tree/?h=\${commit}";
|
|
|
|
file = "/tree/\${file}?h=\${commit}";
|
|
|
|
filehistory = "/log/\${file}?h=\${branch}";
|
|
|
|
linkname = "cgit";
|
2020-06-11 23:49:37 +02:00
|
|
|
};
|
|
|
|
|
2020-08-30 18:25:45 +02:00
|
|
|
# Auto-link panettone bug links
|
|
|
|
commentlink.panettone = {
|
2020-09-01 01:09:35 +02:00
|
|
|
match = "b/(\\\\d+)";
|
2020-08-30 18:25:45 +02:00
|
|
|
html = "<a href=\"https://b.tvl.fyi/issues/$1\">b/$1</a>";
|
|
|
|
};
|
|
|
|
|
2021-04-10 17:25:10 +02:00
|
|
|
# Auto-link other CLs
|
|
|
|
commentlink.gerrit = {
|
|
|
|
match = "cl/(\\\\d+)";
|
|
|
|
html = "<a href=\"https://cl.tvl.fyi/$1\">cl/$1</a>";
|
|
|
|
};
|
|
|
|
|
2021-04-03 17:54:42 +02:00
|
|
|
# Configures integration with CAS, which then integrates with a variety
|
|
|
|
# of backends.
|
|
|
|
auth.type = "OAUTH";
|
|
|
|
plugin.gerrit-oauth-provider-cas-oauth = {
|
|
|
|
root-url = "https://login.tvl.fyi";
|
|
|
|
client-id = "OAUTH-TVL-gerrit-Fv0d8Aizz5";
|
|
|
|
# client-secret is set in /var/lib/gerrit/etc/secure.config.
|
2020-06-08 02:35:45 +02:00
|
|
|
};
|
2020-06-13 00:19:34 +02:00
|
|
|
|
2021-08-15 11:56:32 +02:00
|
|
|
# Allow users to add additional email addresses to their accounts.
|
|
|
|
oauth.allowRegisterNewEmail = true;
|
|
|
|
|
2021-04-03 17:54:42 +02:00
|
|
|
# Use Gerrit's built-in HTTP passwords, rather than trying to use the
|
|
|
|
# password against the backing OAuth provider.
|
|
|
|
auth.gitBasicAuthPolicy = "HTTP";
|
|
|
|
|
2020-06-13 00:19:34 +02:00
|
|
|
# Email sending (emails are relayed via the tazj.in domain's
|
|
|
|
# GSuite currently).
|
|
|
|
#
|
|
|
|
# Note that sendemail.smtpPass is stored in
|
|
|
|
# $site_path/etc/secure.config and is *not* controlled by Nix.
|
|
|
|
#
|
|
|
|
# Receiving email is not currently supported.
|
|
|
|
sendemail = {
|
|
|
|
enable = true;
|
|
|
|
html = false;
|
2020-06-13 03:21:40 +02:00
|
|
|
connectTimeout = "10sec";
|
2020-06-13 00:19:34 +02:00
|
|
|
from = "TVL Code Review <tvlbot@tazj.in>";
|
|
|
|
includeDiff = true;
|
2020-06-13 03:21:40 +02:00
|
|
|
smtpEncryption = "none";
|
|
|
|
smtpServer = "localhost";
|
|
|
|
smtpServerPort = 2525;
|
2020-06-13 00:19:34 +02:00
|
|
|
};
|
2020-06-07 20:30:52 +02:00
|
|
|
};
|
|
|
|
};
|
2020-06-11 23:47:41 +02:00
|
|
|
|
|
|
|
systemd.services.gerrit = {
|
|
|
|
serviceConfig = {
|
|
|
|
# There seems to be no easy way to get `DynamicUser` to play
|
|
|
|
# well with other services (e.g. by using SupplementaryGroups,
|
|
|
|
# which seem to have no effect) so we force the DynamicUser
|
|
|
|
# setting for the Gerrit service to be disabled and reuse the
|
|
|
|
# existing 'git' user.
|
|
|
|
DynamicUser = lib.mkForce false;
|
|
|
|
User = "git";
|
|
|
|
Group = "git";
|
|
|
|
};
|
|
|
|
};
|
2021-09-18 16:44:40 +02:00
|
|
|
|
|
|
|
services.depot.restic = {
|
|
|
|
paths = [ "/var/lib/gerrit" ];
|
|
|
|
exclude = [ "/var/lib/gerrit/tmp" ];
|
|
|
|
};
|
2020-06-07 20:30:52 +02:00
|
|
|
}
|