From 3fa5048737bf0754fc48af7bcd228c55974e4683 Mon Sep 17 00:00:00 2001 From: Yaya Date: Mon, 8 Jul 2024 08:19:38 +0200 Subject: [PATCH] gitaly: build bundled git from source --- .../gitlab/gitaly/default.nix | 9 ++- .../version-management/gitlab/gitaly/git.nix | 57 +++++++++++++++++++ .../version-management/gitlab/update.py | 8 +++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 pkgs/applications/version-management/gitlab/gitaly/git.nix diff --git a/pkgs/applications/version-management/gitlab/gitaly/default.nix b/pkgs/applications/version-management/gitlab/gitaly/default.nix index ce29540eb100..f41248123934 100644 --- a/pkgs/applications/version-management/gitlab/gitaly/default.nix +++ b/pkgs/applications/version-management/gitlab/gitaly/default.nix @@ -1,4 +1,5 @@ { lib +, callPackage , fetchFromGitLab , buildGoModule , pkg-config @@ -9,6 +10,8 @@ let package_version = "v${lib.versions.major version}"; gitaly_package = "gitlab.com/gitlab-org/gitaly/${package_version}"; + git = callPackage ./git.nix { }; + commonOpts = { inherit version; @@ -26,8 +29,6 @@ let tags = [ "static" ]; - nativeBuildInputs = [ pkg-config ]; - doCheck = false; }; @@ -49,6 +50,10 @@ buildGoModule ({ outputs = [ "out" ]; + passthru = { + inherit git; + }; + meta = with lib; { homepage = "https://gitlab.com/gitlab-org/gitaly"; description = "Git RPC service for handling all the git calls made by GitLab"; diff --git a/pkgs/applications/version-management/gitlab/gitaly/git.nix b/pkgs/applications/version-management/gitlab/gitaly/git.nix new file mode 100644 index 000000000000..b80f5de40668 --- /dev/null +++ b/pkgs/applications/version-management/gitlab/gitaly/git.nix @@ -0,0 +1,57 @@ +{ stdenv +, lib +, gitaly +, fetchFromGitLab +, curl +, pcre2 +, zlib +}: + +stdenv.mkDerivation rec { + pname = "gitaly-git"; + version = "2.44.1.gl1"; + + # `src` attribute for nix-update + src = fetchFromGitLab { + owner = "gitlab-org"; + repo = "git"; + rev = "v${version}"; + hash = "sha256-1XtzM2dYbt3nsYOm5isgHnolfziyIC9yCTkfLJ95V6Y="; + }; + + # we actually use the gitaly build system + 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 + ''; + sourceRoot = "source"; + + buildFlags = [ "git" ]; + + buildInputs = [ + curl + pcre2 + zlib + ]; + + # The build phase already installs it all + GIT_PREFIX = placeholder "out"; + dontInstall = true; + + meta = { + homepage = "https://git-scm.com/"; + description = "Distributed version control system - with Gitaly patches"; + license = lib.licenses.gpl2Only; + platforms = lib.platforms.all; + maintainers = lib.teams.gitlab.members; + }; +} diff --git a/pkgs/applications/version-management/gitlab/update.py b/pkgs/applications/version-management/gitlab/update.py index 5c5aacda3d92..ee723769b761 100755 --- a/pkgs/applications/version-management/gitlab/update.py +++ b/pkgs/applications/version-management/gitlab/update.py @@ -245,8 +245,16 @@ def update_gitaly(): logger.info("Updating gitaly") data = _get_data_json() gitaly_server_version = data['passthru']['GITALY_SERVER_VERSION'] + repo = GitLabRepo(repo="gitaly") + gitaly_dir = pathlib.Path(__file__).parent / 'gitaly' + + makefile = repo.get_file("Makefile", f"v{gitaly_server_version}") + makefile += "\nprint-%:;@echo $($*)\n" + + git_version = subprocess.run(["make", "-f", "-", "print-GIT_VERSION"], check=True, input=makefile, text=True, capture_output=True).stdout.strip() _call_nix_update("gitaly", gitaly_server_version) + _call_nix_update("gitaly.git", git_version) @cli.command("update-gitlab-pages")