Commit 86fc7533 authored by Leona Maroni's avatar Leona Maroni Committed by Yaya
Browse files

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.
parent 42f292a5
Loading
Loading
Loading
Loading
+39 −13
Original line number Diff line number Diff line
@@ -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 = src.name;

  buildFlags = [ "git" ];
  GIT_REPO_URL = src;
  HOME = "/build";

  nativeBuildInputs = [
    git # clones our repo from the store
    pkg-config
  ];
  # git inputs
  buildInputs = [
    curl
    pcre2
    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";
+24 −2
Original line number Diff line number Diff line
@@ -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" ];
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,11 @@ buildGoModule rec {
  vendorHash = "sha256-OubXCpvGtGqegQmdb6R1zw/0DfQ4FdbJGt7qYYRnWnA=";
  subPackages = [ "." ];

  ldflags = [
    "-X"
    "main.VERSION=${version}"
  ];

  meta = {
    description = "Daemon used to serve static websites for GitLab users";
    mainProgram = "gitlab-pages";