From f01c7ebc2b79b1e3679a09fc36cb4c80b716b390 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Mon, 19 Jan 2026 19:38:26 -0500 Subject: [PATCH] git: fix build with osxkeychain Cherry-pick a patch from Git next and make further adjustments to allow it to build in our environment. --- .../gi/git/osxkeychain-link-rust_lib.patch | 15 +++++++++++++++ pkgs/by-name/gi/git/package.nix | 13 ++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 pkgs/by-name/gi/git/osxkeychain-link-rust_lib.patch diff --git a/pkgs/by-name/gi/git/osxkeychain-link-rust_lib.patch b/pkgs/by-name/gi/git/osxkeychain-link-rust_lib.patch new file mode 100644 index 000000000000..a0015f87888d --- /dev/null +++ b/pkgs/by-name/gi/git/osxkeychain-link-rust_lib.patch @@ -0,0 +1,15 @@ +diff -ur a/Makefile b/Makefile +--- a/Makefile 2026-02-14 15:58:16.624434564 -0500 ++++ b/Makefile 2026-02-14 15:59:25.701016105 -0500 +@@ -4059,9 +4059,9 @@ + contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT) + $(AR) $(ARFLAGS) $@ $^ + +-contrib/credential/osxkeychain/git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain.o $(LIB_FILE) GIT-LDFLAGS ++contrib/credential/osxkeychain/git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain.o $(LIB_FILE) $(RUST_LIB) GIT-LDFLAGS + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \ +- $(filter %.o,$^) $(LIB_FILE) $(EXTLIBS) -framework Security -framework CoreFoundation ++ $(filter %.o,$^) $(LIB_FILE) $(RUST_LIB) $(EXTLIBS) -framework Security -framework CoreFoundation + + contrib/credential/osxkeychain/git-credential-osxkeychain.o: contrib/credential/osxkeychain/git-credential-osxkeychain.c GIT-CFLAGS + $(QUIET_LINK)$(CC) -o $@ -c $(dep_args) $(compdb_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $< diff --git a/pkgs/by-name/gi/git/package.nix b/pkgs/by-name/gi/git/package.nix index ac45ac28217c..49be29b17628 100644 --- a/pkgs/by-name/gi/git/package.nix +++ b/pkgs/by-name/gi/git/package.nix @@ -130,6 +130,17 @@ stdenv.mkDerivation (finalAttrs: { url = "https://lore.kernel.org/git/20251201031040.1120091-1-brianmlyles@gmail.com/raw"; hash = "sha256-vvhbvg74OIMzfksHiErSnjOZ+W0M/T9J8GOQ4E4wKbU="; }) + # Fix build failure on Darwin when building Keychain integration + # See https://github.com/git/git/pull/2188 and https://github.com/Homebrew/homebrew-core/pull/266961 + (fetchurl { + name = "osxkeychain-define-build-targets-in-toplevel-Makefile.patch"; + url = "https://lore.kernel.org/git/pull.2046.v2.git.1770775169908.gitgitgadget@gmail.com/raw"; + hash = "sha256-7jTiMM5XFRDj/srtVf8olW62T/mesqLcyRp3NZJcid8="; + }) + ] + ++ lib.optionals rustSupport [ + # The above patch doesn’t work with Rust support enabled. + ./osxkeychain-link-rust_lib.patch ] ++ lib.optionals withSsh [ # Hard-code the ssh executable to ${pkgs.openssh}/bin/ssh instead of @@ -271,7 +282,7 @@ stdenv.mkDerivation (finalAttrs: { make -C contrib/diff-highlight "''${flagsArray[@]}" '' + lib.optionalString osxkeychainSupport '' - make -C contrib/credential/osxkeychain "''${flagsArray[@]}" + make -C contrib/credential/osxkeychain COMPUTE_HEADER_DEPENDENCIES=no "''${flagsArray[@]}" '' + lib.optionalString withLibsecret '' make -C contrib/credential/libsecret "''${flagsArray[@]}"