2020-06-07 20:30:52 +02:00
|
|
|
# Gerrit configuration for the TVL monorepo
|
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
|
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
|
|
|
|
ln -s ${config.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
|
|
|
|
2020-06-13 20:30:48 +02:00
|
|
|
plugins = with config.depot.third_party.gerrit_plugins; [
|
2020-07-26 14:53:34 +02:00
|
|
|
checks
|
2020-06-13 20:30:48 +02:00
|
|
|
owners
|
|
|
|
];
|
|
|
|
|
2020-06-14 19:58:53 +02:00
|
|
|
package = config.depot.third_party.gerrit;
|
|
|
|
|
2020-07-11 02:35:00 +02:00
|
|
|
jvmHeapLimit = "4g";
|
|
|
|
|
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"
|
|
|
|
];
|
|
|
|
|
2020-06-20 05:36:56 +02:00
|
|
|
# Configure for Sourcegraph.
|
2020-06-11 23:49:37 +02:00
|
|
|
gitweb = {
|
|
|
|
type = "custom";
|
2020-06-20 05:36:56 +02:00
|
|
|
url = "https://cs.tvl.fyi";
|
|
|
|
linkname = "Sourcegraph";
|
|
|
|
project = "/depot";
|
|
|
|
revision = "/depot/-/commit/\${commit}";
|
|
|
|
branch = "/depot@\${branch}";
|
|
|
|
tag = "/depot@\${tag}";
|
|
|
|
roottree = "/depot@\${commit}";
|
|
|
|
file = "/depot@\${commit}/-/blob/\${file}";
|
|
|
|
filehistory = "/depot@\${commit}/-/blob/\${file}#&tab=history";
|
2020-06-11 23:49:37 +02:00
|
|
|
};
|
|
|
|
|
2020-06-08 02:35:45 +02:00
|
|
|
# Configures integration with the locally running OpenLDAP
|
|
|
|
auth.type = "LDAP";
|
|
|
|
ldap = {
|
|
|
|
server = "ldap://localhost";
|
|
|
|
accountBase = "ou=users,dc=tvl,dc=fyi";
|
|
|
|
accountPattern = "(&(objectClass=organizationalPerson)(cn=\${username}))";
|
2020-06-17 04:53:56 +02:00
|
|
|
accountFullName = "displayName";
|
2020-06-08 02:35:45 +02:00
|
|
|
accountEmailAddress = "mail";
|
2020-06-11 01:04:05 +02:00
|
|
|
accountSshUserName = "cn";
|
2020-06-08 02:35:45 +02:00
|
|
|
groupBase = "ou=groups,dc=tvl,dc=fyi";
|
|
|
|
|
|
|
|
# TODO(tazjin): Assuming this is what we'll be doing ...
|
|
|
|
groupMemberPattern = "(&(objectClass=group)(member=\${dn}))";
|
|
|
|
};
|
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";
|
|
|
|
};
|
|
|
|
};
|
2020-06-07 20:30:52 +02:00
|
|
|
}
|