From f47d448f97ecd892a305d865b46d8ab126bb0ec8 Mon Sep 17 00:00:00 2001 From: Leona Maroni Date: Tue, 26 Aug 2025 17:54:08 +0200 Subject: [PATCH] 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 86fc7533fb29f3d04493c2e28d186e14a6d94169) --- pkgs/by-name/gi/gitaly/git.nix | 58 +++++++++++++++++------- pkgs/by-name/gi/gitaly/package.nix | 26 ++++++++++- pkgs/by-name/gi/gitlab-pages/package.nix | 5 ++ 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/pkgs/by-name/gi/gitaly/git.nix b/pkgs/by-name/gi/gitaly/git.nix index 654c710d0da8..3e1bc12495d4 100644 --- a/pkgs/by-name/gi/gitaly/git.nix +++ b/pkgs/by-name/gi/gitaly/git.nix @@ -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"; diff --git a/pkgs/by-name/gi/gitaly/package.nix b/pkgs/by-name/gi/gitaly/package.nix index 23e1808c6324..356200af8610 100644 --- a/pkgs/by-name/gi/gitaly/package.nix +++ b/pkgs/by-name/gi/gitaly/package.nix @@ -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" ]; diff --git a/pkgs/by-name/gi/gitlab-pages/package.nix b/pkgs/by-name/gi/gitlab-pages/package.nix index b577ff7d7b92..4c1266d11618 100644 --- a/pkgs/by-name/gi/gitlab-pages/package.nix +++ b/pkgs/by-name/gi/gitlab-pages/package.nix @@ -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";