feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
{ 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
|
2020-11-27 18:39:35 +01:00
|
|
|
pkgs.jdk11_headless
|
feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
pkgs.zlib
|
|
|
|
pkgs.python
|
|
|
|
pkgs.curl
|
|
|
|
pkgs.nodejs
|
|
|
|
pkgs.yarn
|
|
|
|
pkgs.git
|
|
|
|
bazelRunScript
|
|
|
|
];
|
|
|
|
runScript = "/bin/bazel-run";
|
|
|
|
};
|
|
|
|
bazel = bazelTop // { override = x: bazelTop; };
|
2020-11-27 18:39:35 +01:00
|
|
|
version = "3.3.0-rc7-520-gdef99cd679";
|
feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
in
|
2020-07-26 14:51:49 +02:00
|
|
|
pkgs.lib.makeOverridable pkgs.buildBazelPackage {
|
2020-11-27 18:39:35 +01:00
|
|
|
pname = "gerrit";
|
|
|
|
inherit version;
|
feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
|
2020-07-26 14:51:49 +02:00
|
|
|
src = pkgs.fetchgit {
|
feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
url = "https://gerrit.googlesource.com/gerrit";
|
2020-12-20 16:08:08 +01:00
|
|
|
rev = "595e6db974449ff278709f5e87cd8d42199305fc";
|
|
|
|
sha256 = "sha256:17mad9k41rvnzq91nr9w2lax6rdk7pgf20qc4chajay99faimhph";
|
feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
fetchSubmodules = true;
|
2020-07-26 14:51:49 +02:00
|
|
|
};
|
2020-06-14 13:36:04 +02:00
|
|
|
patches = [
|
2020-07-03 00:28:39 +02:00
|
|
|
./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
|
2020-07-11 02:48:54 +02:00
|
|
|
./0005-When-using-local-fonts-always-assume-Gerrit-is-mount.patch
|
|
|
|
./0006-Always-use-Google-Fonts.patch
|
2020-12-20 16:12:40 +01:00
|
|
|
./0007-Keep-left-padding-on-account-chip-if-no-avatar-provi.patch
|
2020-06-14 13:36:04 +02:00
|
|
|
];
|
feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
|
|
|
|
bazelTarget = "release";
|
|
|
|
inherit bazel;
|
|
|
|
|
|
|
|
bazelFlags = [
|
|
|
|
"--repository_cache="
|
|
|
|
"--disk_cache="
|
|
|
|
];
|
|
|
|
removeRulesCC = false;
|
2020-11-27 18:39:35 +01:00
|
|
|
fetchConfigured = true;
|
feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
|
|
|
|
fetchAttrs = {
|
2021-03-21 13:38:12 +01:00
|
|
|
sha256 = "sha256:0jlaylzbl2yscdfji77g1k4r3lcdmjxfbcxpnpwbcs83zpg8rsmf";
|
feat(gerrit): Create Gerrit derivation.
This uses the actual Bazel build, using a variety of tricks and hacks to
make it actually work.
Bazel really wants to download linux binaries from the internet and run
them. In lieu of trying to fix the build system to not do this, we
instead put bazel inside an FHS environment, which allows the binaries
to find their dependencies.
We also have to patch a few things:
* We use build --nobuild instead of fetch, so we only fetch the
dependencies we actually need for the build and not, say, Windows
binaries.
* We don't remove rules_cc, because we need it as an external
dependency, not bundled.
* We do some manual fixes on the cache before packing, because we need
to remove some in-tree sources (so they don't cause the hash to break,
since the hashes differ each time they're generated), and also remove
some extraneous files.
* We explicitly turn off the repository and disk caches, because the
.bazelrc at the root of the Gerrit tree turns them on, with paths
pointing into the user's home directory.
* detzip is used instead of the zip binary for packing bower_components
into an archive. detzip doesn't create entries for directories, and
also doesn't store most metadata (timestamps, etc.), and uses store
(i.e. uncompressed) compression only. It also sorts the file tree
before writing them into the file.
Change-Id: I572c43f7175067ecb1b85cdf40dda13a52de1439
Reviewed-on: https://cl.tvl.fyi/c/depot/+/252
Reviewed-by: tazjin <mail@tazj.in>
2020-06-14 13:23:47 +02:00
|
|
|
preBuild = ''
|
|
|
|
rm .bazelversion
|
|
|
|
'';
|
|
|
|
|
|
|
|
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"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|