Compare commits

...

2 commits

Author SHA1 Message Date
raito cbf08cc4e6 feat: introduce Gerrit 3.11
Plugins are not upgraded yet, I am not sure how we would like to handle
this.

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2024-12-14 16:26:24 +01:00
raito cb99a5eebd chore: upgrade nixpkgs
This requires a bump for the dependency FOD of Gerrit 3.10 as well.

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2024-12-14 16:26:02 +01:00
5 changed files with 290 additions and 134 deletions

View file

@ -5,22 +5,54 @@
, pkgs ? import nixpkgs { }
, lib ? pkgs.lib
}:
let
mkPluginSet = { self, buildGerritBazelPlugin }: {
code-owners = self.callPackage ./plugins/code-owners {
inherit buildGerritBazelPlugin;
};
oauth = self.callPackage ./plugins/oauth {
inherit buildGerritBazelPlugin;
};
metrics-reporter-prometheus = self.callPackage ./plugins/metrics-reporter-prometheus {
inherit buildGerritBazelPlugin;
};
};
in
lib.makeScope pkgs.newScope (self: {
buildBazelPackageNG = self.callPackage ./buildBazelPackageNG { };
gerrit = self.callPackage ./gerrit { };
inherit (self.callPackage ./gerrit { }) gerrit_3_10 gerrit_3_11;
buildGerritBazelPlugin = self.callPackage ./plugins/builder.nix { };
plugins = {
code-owners = self.callPackage ./plugins/code-owners { };
oauth = self.callPackage ./plugins/oauth { };
metrics-reporter-prometheus = self.callPackage ./plugins/metrics-reporter-prometheus { };
buildGerrit310BazelPlugin = self.callPackage ./plugins/builder.nix {
gerrit = self.gerrit_3_10;
};
buildGerrit311BazelPlugin = self.callPackage ./plugins/builder.nix {
gerrit = self.gerrit_3_11;
};
ci = pkgs.linkFarm "gerrit-ci" [
plugins_3_10 = mkPluginSet {
inherit self;
buildGerritBazelPlugin = self.buildGerrit310BazelPlugin;
};
plugins_3_11 = mkPluginSet {
inherit self;
buildGerritBazelPlugin = self.buildGerrit311BazelPlugin;
};
buildGerritBazelPlugin = self.buildGerrit310BazelPlugin;
gerrit = self.gerrit_3_10;
plugins = self.plugins_3_10;
ci = pkgs.linkFarm "gerrit-${self.gerrit.version}-ci" [
{ name = "gerrit"; path = self.gerrit; }
{ name = "code-owners.jar"; path = self.plugins.code-owners; }
{ name = "oauth.jar"; path = self.plugins.oauth; }
{ name = "metrics-reporter-prometheus.jar"; path = self.plugins.metrics-reporter-prometheus; }
];
ci-next = pkgs.linkFarm "gerrit-${self.gerrit_3_11.version}-ci" [
{ name = "gerrit"; path = self.gerrit_3_11; }
{ name = "code-owners.jar"; path = self.plugins_3_11.code-owners; }
{ name = "oauth.jar"; path = self.plugins_3_11.oauth; }
{ name = "metrics-reporter-prometheus.jar"; path = self.plugins_3_11.metrics-reporter-prometheus; }
];
})

View file

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1720031269,
"narHash": "sha256-rwz8NJZV+387rnWpTYcXaRNvzUSnnF9aHONoJIYmiUQ=",
"lastModified": 1733940404,
"narHash": "sha256-Pj39hSoUA86ZePPF/UXiYHHM7hMIkios8TYG29kQT4g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9f4128e00b0ae8ec65918efeba59db998750ead6",
"rev": "5d67ea6b4b63378b9c13be21e2ec9d1afc921713",
"type": "github"
},
"original": {

123
gerrit/3_10.nix Normal file
View file

@ -0,0 +1,123 @@
# SPDX-FileCopyrightText: 2024 The nix-gerrit Authors <git@lukegb.com>
# SPDX-License-Identifier: MIT
{ buildBazelPackageNG
, lib
, fetchgit
, bazel_7
, python3
, openjdk21_headless
, curl
, unzip
, extraBazelPackageAttrs ? {}
}:
let
inherit (buildBazelPackageNG) bazelRulesJavaHook bazelRulesNodeJS5Hook;
in
(buildBazelPackageNG rec {
pname = "gerrit";
version = "3.10.0";
bazel = bazel_7;
src = (fetchgit {
url = "https://gerrit.googlesource.com/gerrit";
rev = "v${version}";
fetchSubmodules = true;
deepClone = true;
hash = "sha256-FpKuzityHuHNYBIOL8YUjCLlkuVBfxjvHECb26NsZNE=";
}).overrideAttrs (_: {
env.NIX_PREFETCH_GIT_CHECKOUT_HOOK = ''
pushd "$dir" >/dev/null
${python3}/bin/python tools/workspace_status_release.py | sort > .version
popd >/dev/null
# delete all the .git; we can't do this using fetchgit if deepClone is on,
# but our mischief has already been achieved by the python command above :)
find "$dir" -name .git -print0 | xargs -0 rm -rf
'';
});
depsHash = "sha256-eX26Bjm7GvzywYeew3705dIwM1ducJw3LsjEYPLn6AM=";
patches = [
./0001-Syntax-highlight-nix.patch
./0002-Syntax-highlight-rules.pl.patch
./0003-Add-titles-to-CLs-over-HTTP.patch
./gerrit-cl-431977-bump-sshd.patch
./gerrit-cl-431977-part-2-bump-bouncycastle.patch
];
nativeBuildInputs = [
bazelRulesJavaHook
bazelRulesNodeJS5Hook
curl
openjdk21_headless
python3
unzip
];
shellHook = ''
bazelFlagsArray+=(
'--javacopt="-XepDisableAllChecks"'
)
'';
prePatch = ''
rm .bazelversion
ln -sf ${./bazelrc} user.bazelrc
ln -sf ${./workspace_overrides.bzl} workspace_overrides.bzl
substituteInPlace WORKSPACE \
--replace-fail 'load("@io_bazel_rules_webtesting//web:repositories.bzl"' 'load("//:workspace_overrides.bzl"' \
--replace-fail 'load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl"' 'load("//:workspace_overrides.bzl"'
patchShebangs Documentation/replace_macros.py
'';
postPatch = ''
sed -Ei 's,^(STABLE_BUILD_GERRIT_LABEL.*)$,\1-dirty-nix,' .version
'';
preBuild = ''
export GERRIT_CACHE_HOME=$NIXBAZEL_CACHE_ROOT/gerrit-cache
'';
extraCacheInstall = ''
cp -R $GERRIT_CACHE_HOME $out/gerrit-cache
'';
extraBuildSetup = ''
ln -sf $deps/gerrit-cache $GERRIT_CACHE_HOME
'';
extraBuildInstall = ''
mkdir -p "$out"/share/api/
unzip bazel-bin/api-skip-javadoc.zip -d "$out"/share/api
'';
bazelTargets = {
"//:release" = "$out/webapps/gerrit-${version}.war";
"//:api-skip-javadoc" = null;
};
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"
];
};
}).override extraBazelPackageAttrs

119
gerrit/3_11.nix Normal file
View file

@ -0,0 +1,119 @@
# SPDX-FileCopyrightText: 2024 The nix-gerrit Authors <git@lukegb.com>
# SPDX-License-Identifier: MIT
{ buildBazelPackageNG
, lib
, fetchgit
, bazel_7
, python3
, openjdk21_headless
, curl
, unzip
, extraBazelPackageAttrs ? {}
}:
let
inherit (buildBazelPackageNG) bazelRulesJavaHook bazelRulesNodeJS5Hook;
in
(buildBazelPackageNG rec {
pname = "gerrit";
version = "3.11.0";
bazel = bazel_7;
src = (fetchgit {
url = "https://gerrit.googlesource.com/gerrit";
rev = "v${version}";
fetchSubmodules = true;
deepClone = true;
hash = "sha256-lnoVx0x3ssa4q/+nVtUSHQJP3NzsEyk8SFhwqgdvEbY=";
}).overrideAttrs (_: {
env.NIX_PREFETCH_GIT_CHECKOUT_HOOK = ''
pushd "$dir" >/dev/null
${python3}/bin/python tools/workspace_status_release.py | sort > .version
popd >/dev/null
# delete all the .git; we can't do this using fetchgit if deepClone is on,
# but our mischief has already been achieved by the python command above :)
find "$dir" -name .git -print0 | xargs -0 rm -rf
'';
});
depsHash = "sha256-pi4bgY1V3mw3rQ91/MchA+Uh8aI9H3gExNPdxMSe2J0=";
patches = [
./0002-Syntax-highlight-rules.pl.patch
./0003-Add-titles-to-CLs-over-HTTP.patch
];
nativeBuildInputs = [
bazelRulesJavaHook
bazelRulesNodeJS5Hook
curl
openjdk21_headless
python3
unzip
];
shellHook = ''
bazelFlagsArray+=(
'--javacopt="-XepDisableAllChecks"'
)
'';
prePatch = ''
rm .bazelversion
ln -sf ${./bazelrc} user.bazelrc
ln -sf ${./workspace_overrides.bzl} workspace_overrides.bzl
substituteInPlace WORKSPACE \
--replace-fail 'load("@io_bazel_rules_webtesting//web:repositories.bzl"' 'load("//:workspace_overrides.bzl"' \
--replace-fail 'load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl"' 'load("//:workspace_overrides.bzl"'
patchShebangs Documentation/replace_macros.py
'';
postPatch = ''
sed -Ei 's,^(STABLE_BUILD_GERRIT_LABEL.*)$,\1-dirty-nix,' .version
'';
preBuild = ''
export GERRIT_CACHE_HOME=$NIXBAZEL_CACHE_ROOT/gerrit-cache
'';
extraCacheInstall = ''
cp -R $GERRIT_CACHE_HOME $out/gerrit-cache
'';
extraBuildSetup = ''
ln -sf $deps/gerrit-cache $GERRIT_CACHE_HOME
'';
extraBuildInstall = ''
mkdir -p "$out"/share/api/
unzip bazel-bin/api-skip-javadoc.zip -d "$out"/share/api
'';
bazelTargets = {
"//:release" = "$out/webapps/gerrit-${version}.war";
"//:api-skip-javadoc" = null;
};
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"
];
};
}).override extraBazelPackageAttrs

View file

@ -1,123 +1,5 @@
# SPDX-FileCopyrightText: 2024 The nix-gerrit Authors <git@lukegb.com>
# SPDX-License-Identifier: MIT
{ buildBazelPackageNG
, lib
, fetchgit
, bazel_7
, python3
, openjdk21_headless
, curl
, unzip
, extraBazelPackageAttrs ? {}
}:
let
inherit (buildBazelPackageNG) bazelRulesJavaHook bazelRulesNodeJS5Hook;
in
(buildBazelPackageNG rec {
pname = "gerrit";
version = "3.10.0";
bazel = bazel_7;
src = (fetchgit {
url = "https://gerrit.googlesource.com/gerrit";
rev = "v${version}";
fetchSubmodules = true;
deepClone = true;
hash = "sha256-FpKuzityHuHNYBIOL8YUjCLlkuVBfxjvHECb26NsZNE=";
}).overrideAttrs (_: {
env.NIX_PREFETCH_GIT_CHECKOUT_HOOK = ''
pushd "$dir" >/dev/null
${python3}/bin/python tools/workspace_status_release.py | sort > .version
popd >/dev/null
# delete all the .git; we can't do this using fetchgit if deepClone is on,
# but our mischief has already been achieved by the python command above :)
find "$dir" -name .git -print0 | xargs -0 rm -rf
'';
});
depsHash = "sha256-mp2RhOvDh+0CeLQhCjPp57N2QB816k4AWMeAhvU2u38=";
patches = [
./0001-Syntax-highlight-nix.patch
./0002-Syntax-highlight-rules.pl.patch
./0003-Add-titles-to-CLs-over-HTTP.patch
./gerrit-cl-431977-bump-sshd.patch
./gerrit-cl-431977-part-2-bump-bouncycastle.patch
];
nativeBuildInputs = [
bazelRulesJavaHook
bazelRulesNodeJS5Hook
curl
openjdk21_headless
python3
unzip
];
shellHook = ''
bazelFlagsArray+=(
'--javacopt="-XepDisableAllChecks"'
)
'';
prePatch = ''
rm .bazelversion
ln -sf ${./bazelrc} user.bazelrc
ln -sf ${./workspace_overrides.bzl} workspace_overrides.bzl
substituteInPlace WORKSPACE \
--replace-fail 'load("@io_bazel_rules_webtesting//web:repositories.bzl"' 'load("//:workspace_overrides.bzl"' \
--replace-fail 'load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl"' 'load("//:workspace_overrides.bzl"'
patchShebangs Documentation/replace_macros.py
'';
postPatch = ''
sed -Ei 's,^(STABLE_BUILD_GERRIT_LABEL.*)$,\1-dirty-nix,' .version
'';
preBuild = ''
export GERRIT_CACHE_HOME=$NIXBAZEL_CACHE_ROOT/gerrit-cache
'';
extraCacheInstall = ''
cp -R $GERRIT_CACHE_HOME $out/gerrit-cache
'';
extraBuildSetup = ''
ln -sf $deps/gerrit-cache $GERRIT_CACHE_HOME
'';
extraBuildInstall = ''
mkdir -p "$out"/share/api/
unzip bazel-bin/api-skip-javadoc.zip -d "$out"/share/api
'';
bazelTargets = {
"//:release" = "$out/webapps/gerrit-${version}.war";
"//:api-skip-javadoc" = null;
};
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"
];
};
}).override extraBazelPackageAttrs
{ callPackage }:
{
gerrit_3_10 = callPackage ./3_10.nix { };
gerrit_3_11 = callPackage ./3_11.nix { };
}