1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

Merge pull request #12863 from Mic92/libgit2

libgit2: use upstream version if possible
This commit is contained in:
Robert Hensing 2025-04-02 22:44:42 +02:00 committed by GitHub
commit 33e638dc1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 55 deletions

View file

@ -171,7 +171,7 @@
{ {
otherSplices = final.generateSplicesForMkScope "nixDependencies"; otherSplices = final.generateSplicesForMkScope "nixDependencies";
f = import ./packaging/dependencies.nix { f = import ./packaging/dependencies.nix {
inherit inputs stdenv; inherit stdenv;
pkgs = final; pkgs = final;
}; };
}; };

View file

@ -1,33 +1,14 @@
# These overrides are applied to the dependencies of the Nix components. # These overrides are applied to the dependencies of the Nix components.
{ {
# Flake inputs; used for sources
inputs,
# The raw Nixpkgs, not affected by this scope # The raw Nixpkgs, not affected by this scope
pkgs, pkgs,
stdenv, stdenv,
}: }:
let
prevStdenv = stdenv;
in
let let
inherit (pkgs) lib; inherit (pkgs) lib;
stdenv = if prevStdenv.isDarwin && prevStdenv.isx86_64 then darwinStdenv else prevStdenv;
# Fix the following error with the default x86_64-darwin SDK:
#
# error: aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on macOS 10.13 or newer
#
# Despite the use of the 10.13 deployment target here, the aligned
# allocation function Clang uses with this setting actually works
# all the way back to 10.6.
darwinStdenv = pkgs.overrideSDK prevStdenv { darwinMinVersion = "10.13"; };
in in
scope: { scope: {
inherit stdenv; inherit stdenv;
@ -65,39 +46,37 @@ scope: {
installPhase = lib.replaceStrings [ "--without-python" ] [ "" ] old.installPhase; installPhase = lib.replaceStrings [ "--without-python" ] [ "" ] old.installPhase;
}); });
libgit2 = pkgs.libgit2.overrideAttrs ( libgit2 =
attrs: if lib.versionAtLeast pkgs.libgit2.version "1.9.0" then
{ pkgs.libgit2
cmakeFlags = attrs.cmakeFlags or [ ] ++ [ "-DUSE_SSH=exec" ]; else
} pkgs.libgit2.overrideAttrs (attrs: {
# libgit2: Nixpkgs 24.11 has < 1.9.0, which needs our patches # libgit2: Nixpkgs 24.11 has < 1.9.0, which needs our patches
// lib.optionalAttrs (!lib.versionAtLeast pkgs.libgit2.version "1.9.0") { nativeBuildInputs =
nativeBuildInputs = attrs.nativeBuildInputs or [ ]
attrs.nativeBuildInputs or [ ] # gitMinimal does not build on Windows. See packbuilder patch.
# gitMinimal does not build on Windows. See packbuilder patch. ++ lib.optionals (!stdenv.hostPlatform.isWindows) [
++ lib.optionals (!stdenv.hostPlatform.isWindows) [ # Needed for `git apply`; see `prePatch`
# Needed for `git apply`; see `prePatch` pkgs.buildPackages.gitMinimal
pkgs.buildPackages.gitMinimal ];
]; # Only `git apply` can handle git binary patches
# Only `git apply` can handle git binary patches prePatch =
prePatch = attrs.prePatch or ""
attrs.prePatch or "" + lib.optionalString (!stdenv.hostPlatform.isWindows) ''
+ lib.optionalString (!stdenv.hostPlatform.isWindows) '' patch() {
patch() { git apply
git apply }
} '';
''; patches =
patches = attrs.patches or [ ]
attrs.patches or [ ] ++ [
++ [ ./patches/libgit2-mempack-thin-packfile.patch
./patches/libgit2-mempack-thin-packfile.patch ]
] # gitMinimal does not build on Windows, but fortunately this patch only
# gitMinimal does not build on Windows, but fortunately this patch only # impacts interruptibility
# impacts interruptibility ++ lib.optionals (!stdenv.hostPlatform.isWindows) [
++ lib.optionals (!stdenv.hostPlatform.isWindows) [ # binary patch; see `prePatch`
# binary patch; see `prePatch` ./patches/libgit2-packbuilder-callback-interruptible.patch
./patches/libgit2-packbuilder-callback-interruptible.patch ];
]; });
}
);
} }