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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
{ depot, pkgs, ... }:
let
detzip = depot.nix.buildGo.program {
name = "detzip";
srcs = [ ./detzip.go ];
};
bazelRunScript = pkgs.writeShellScriptBin "bazel-run" ''
yarn config set cache-folder "$bazelOut/external/yarn_cache"
export HOME="$bazelOut/external/home"
mkdir -p "$bazelOut/external/home"
exec /bin/bazel "$@"
'';
bazelTop = pkgs.buildFHSUserEnv {
name = "bazel";
targetPkgs = pkgs: [
(pkgs.bazel.override { enableNixHacks = true; })
detzip
pkgs.jdk
pkgs.zlib
pkgs.python
pkgs.curl
pkgs.nodejs
pkgs.yarn
pkgs.git
bazelRunScript
];
runScript = "/bin/bazel-run";
};
bazel = bazelTop // { override = x: bazelTop; };
version = "3.2.2-1002-gea26b5ee7a";
in
pkgs.lib.makeOverridable pkgs.buildBazelPackage {
name = "gerrit-${version}";
src = pkgs.fetchgit {
url = "https://gerrit.googlesource.com/gerrit";
rev = "ea26b5ee7a1c1e4042525d308678570101d4d4d6";
sha256 = "1bndmk7namb81zkscmpvf8ygwrj0wh842xbj0irgbm5w2xwdzkch";
fetchSubmodules = true;
deepClone = true;
leaveDotGit = true;
};
patches = [
./0001-Use-detzip-in-download_bower.py.patch
./0002-Syntax-highlight-nix.patch
./0003-Syntax-highlight-rules.pl.patch
./0004-Add-titles-to-CLs-over-HTTP.patch
./0005-When-using-local-fonts-always-assume-Gerrit-is-mount.patch
./0006-Always-use-Google-Fonts.patch
./0007-Fix-gr-hovercard-behavior-under-Firefox.patch
];
bazelTarget = "release";
inherit bazel;
bazelFlags = [
"--repository_cache="
"--disk_cache="
];
removeRulesCC = false;
fetchAttrs = {
sha256 = "0jhvcpzkpcanxm99grgk6giv8yf2j0zix5z91wbnz6hb0isps5hs";
preBuild = ''
rm .bazelversion
'';
buildPhase = ''
runHook preBuild
BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 \
USER=homeless-shelter \
bazel \
--output_base="$bazelOut" \
--output_user_root="$bazelUserRoot" \
build --nobuild \
--loading_phase_threads=1 \
$bazelFlags \
$bazelFetchFlags \
$bazelTarget
runHook postBuild
'';
installPhase = ''
runHook preInstall
# Remove all built in external workspaces, Bazel will recreate them when building
rm -rf $bazelOut/external/{bazel_tools,\@bazel_tools.marker}
rm -rf $bazelOut/external/{embedded_jdk,\@embedded_jdk.marker}
rm -rf $bazelOut/external/{local_config_cc,\@local_config_cc.marker}
rm -rf $bazelOut/external/{local_*,\@local_*.marker}
# Clear markers
find $bazelOut/external -name '@*\.marker' -exec sh -c 'echo > {}' \;
# Remove all vcs files
rm -rf $(find $bazelOut/external -type d -name .git)
rm -rf $(find $bazelOut/external -type d -name .svn)
rm -rf $(find $bazelOut/external -type d -name .hg)
# Removing top-level symlinks along with their markers.
# This is needed because they sometimes point to temporary paths (?).
# For example, in Tensorflow-gpu build:
# platforms -> NIX_BUILD_TOP/tmp/install/35282f5123611afa742331368e9ae529/_embedded_binaries/platforms
find $bazelOut/external -maxdepth 1 -type l | while read symlink; do
name="$(basename "$symlink")"
rm -rf "$symlink" "$bazelOut/external/@$name.marker"
done
# Patching symlinks to remove build directory reference
find $bazelOut/external -type l | while read symlink; do
new_target="$(readlink "$symlink" | sed "s,$NIX_BUILD_TOP,NIX_BUILD_TOP,")"
rm "$symlink"
ln -sf "$new_target" "$symlink"
done
echo '${bazel.name}' > $bazelOut/external/.nix-bazel-version
# Gerrit fixups:
# Remove polymer-bridges and ba-linkify, they're in-repo
rm -rf $bazelOut/external/yarn_cache/v6/npm-polymer-bridges-*
rm -rf $bazelOut/external/yarn_cache/v6/npm-ba-linkify-*
# Normalize permissions on .yarn-{tarball,metadata} files
find $bazelOut/external/yarn_cache \( -name .yarn-tarball.tgz -or -name .yarn-metadata.json \) -exec chmod 644 {} +
(cd $bazelOut/ && tar czf $out --sort=name --mtime='@1' --owner=0 --group=0 --numeric-owner external/)
runHook postInstall
'';
};
buildAttrs = {
preConfigure = ''
rm .bazelversion
'';
installPhase = ''
mkdir -p "$out"/webapps/
cp bazel-bin/release.war "$out"/webapps/gerrit-${version}.war
'';
};
passthru = {
# A list of plugins that are part of the gerrit.war file.
# Use `java -jar gerrit.war ls | grep -Po '(?<=plugins/)[^.]+' | sed -e 's,^,",' -e 's,$,",' | sort` to generate that list.
plugins = [
"codemirror-editor"
"commit-message-length-validator"
"delete-project"
"download-commands"
"gitiles"
"hooks"
"plugin-manager"
"replication"
"reviewnotes"
"singleusergroup"
"webhooks"
];
};
}
|