gitaly: fix build with >=18.3

This fixes build issues with gitaly >=18.3.
This change authored by Helsinki Systems. Thank you for providing this.

(cherry picked from commit 86fc7533fb)
This commit is contained in:
Leona Maroni
2025-08-26 17:54:08 +02:00
committed by Yaya
parent 9778e06239
commit f47d448f97
3 changed files with 71 additions and 18 deletions

View File

@@ -6,6 +6,9 @@
curl,
pcre2,
zlib,
git,
pkg-config,
openssl,
}:
stdenv.mkDerivation rec {
@@ -17,37 +20,60 @@ stdenv.mkDerivation rec {
owner = "gitlab-org";
repo = "git";
rev = "v${version}";
hash = "sha256-1y94T5UBG7s76ENsUmaXRXngSKmqIAT0nq1u+QjSWaY=";
hash = "sha256-VFqUz79RvkOE4CS8GUZTPhah2AbvrlyHr4iYhWqh61Y=";
leaveDotGit = true;
# The build system clones the repo from the store (since it always expects
# to be able to clone in the makefiles) and it looks like nix doesn't leave
# the tag so we re-add it.
postFetch = ''
git -C $out tag v${version};
'';
};
# we actually use the gitaly build system
# Use gitaly and their build system as source root
unpackPhase = ''
cp -r ${gitaly.src} source
chmod -R +w source
mkdir -p source/_build/deps
cp -r ${src} source/_build/deps/git-distribution
chmod -R +w source/_build/deps/git-distribution
# FIXME? maybe just patch the makefile?
echo -n 'v${version} DEVELOPER=1 DEVOPTS=no-error USE_LIBPCRE=YesPlease NO_PERL=YesPlease NO_EXPAT=YesPlease NO_TCLTK=YesPlease NO_GETTEXT=YesPlease NO_PYTHON=YesPlease' > source/_build/deps/git-distribution.version
echo -n 'v${version}' > source/_build/deps/git-distribution/version
git config --global --add safe.directory '*'
'';
sourceRoot = "source";
sourceRoot = src.name;
buildFlags = [ "git" ];
GIT_REPO_URL = src;
HOME = "/build";
buildInputs = [
curl
pcre2
zlib
nativeBuildInputs = [
git # clones our repo from the store
pkg-config
];
# git inputs
buildInputs = [
openssl
zlib
pcre2
curl
];
# required to support pthread_cancel()
NIX_LDFLAGS =
lib.optionalString (stdenv.cc.isGNU && stdenv.hostPlatform.libc == "glibc") "-lgcc_s"
+ lib.optionalString stdenv.isFreeBSD "-lthr";
# The build phase already installs it all
GIT_PREFIX = placeholder "out";
dontInstall = true;
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
HOME=/build PAGER=cat $out/bin/git config -l
file $out/bin/git | grep -qv 'too large section header'
runHook postInstallCheck
'';
meta = {
homepage = "https://git-scm.com/";
description = "Distributed version control system - with Gitaly patches";

View File

@@ -33,6 +33,8 @@ let
tags = [ "static" ];
nativeBuildInputs = [ pkg-config ];
doCheck = false;
};
@@ -41,6 +43,7 @@ let
pname = "gitaly-aux";
subPackages = [
# Can be determined by looking at the `go:embed` calls in https://gitlab.com/gitlab-org/gitaly/-/blob/master/packed_binaries.go
"cmd/gitaly-hooks"
"cmd/gitaly-ssh"
"cmd/gitaly-lfs-smudge"
@@ -59,12 +62,31 @@ buildGoModule (
"cmd/gitaly-backup"
];
dontStrip = true;
preConfigure = ''
rm -r tools
mkdir -p _build/bin
cp -r ${auxBins}/bin/* _build/bin
for f in ${git}/bin/git-*; do
cp "$f" "_build/bin/gitaly-$(basename $f)";
# Add git that will be embedded
echo 'print-%:;@echo $($*)' >> Makefile
sed -i 's:/usr/bin/env ::g' Makefile
for bin in $(make print-GIT_PACKED_EXECUTABLES); do
from="$(basename "$bin")"
from="''${from#gitaly-}"
from="${git}/libexec/git-core/''${from%-*}"
cp "$from" "$bin"
done
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
HOME=/build PAGER=cat ${git}/bin/git config -l
runHook postInstallCheck
'';
outputs = [ "out" ];

View File

@@ -19,6 +19,11 @@ buildGoModule rec {
vendorHash = "sha256-OubXCpvGtGqegQmdb6R1zw/0DfQ4FdbJGt7qYYRnWnA=";
subPackages = [ "." ];
ldflags = [
"-X"
"main.VERSION=${version}"
];
meta = with lib; {
description = "Daemon used to serve static websites for GitLab users";
mainProgram = "gitlab-pages";