Merge pull request #39425 from bgamari/git-cross

Allow git to be cross-compiled

authored by John Ericson and committed by GitHub 4aefe8a4 5979e886

+32 -17
+32 -17
pkgs/applications/version-management/git-and-tools/git/default.nix
··· 4 4 , asciidoc, texinfo, xmlto, docbook2x, docbook_xsl, docbook_xml_dtd_45 5 5 , libxslt, tcl, tk, makeWrapper, libiconv 6 6 , svnSupport, subversionClient, perlLibs, smtpPerlLibs 7 + , perlSupport ? true 7 8 , guiSupport 8 9 , withManual ? true 9 10 , pythonSupport ? true ··· 11 12 , sendEmailSupport 12 13 , darwin 13 14 }: 15 + 16 + assert sendEmailSupport -> perlSupport; 17 + assert svnSupport -> perlSupport; 14 18 15 19 let 16 20 version = "2.16.3"; 17 - svn = subversionClient.override { perlBindings = true; }; 21 + svn = subversionClient.override { perlBindings = perlSupport; }; 18 22 in 19 23 20 24 stdenv.mkDerivation { ··· 25 29 sha256 = "0j1dwvg5llnj3g0fp8hdgpms4hp90qw9f6509vqw30dhwplrjpfn"; 26 30 }; 27 31 28 - outputs = [ "out" "gitweb" ]; 32 + outputs = [ "out" ] ++ stdenv.lib.optional perlSupport "gitweb"; 29 33 30 34 hardeningDisable = [ "format" ]; 31 35 ··· 44 48 done 45 49 ''; 46 50 47 - buildInputs = [curl openssl zlib expat gettext cpio makeWrapper libiconv perl] 51 + nativeBuildInputs = [ gettext perl ] 48 52 ++ stdenv.lib.optionals withManual [ asciidoc texinfo xmlto docbook2x 49 - docbook_xsl docbook_xml_dtd_45 libxslt ] 53 + docbook_xsl docbook_xml_dtd_45 libxslt ]; 54 + buildInputs = [curl openssl zlib expat cpio makeWrapper libiconv] 55 + ++ stdenv.lib.optionals perlSupport [ perl ] 50 56 ++ stdenv.lib.optionals guiSupport [tcl tk] 51 57 ++ stdenv.lib.optionals withpcre2 [ pcre2 ] 52 58 ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.Security ]; ··· 56 62 NIX_LDFLAGS = stdenv.lib.optionalString (!stdenv.cc.isClang) "-lgcc_s" 57 63 + stdenv.lib.optionalString (stdenv.isFreeBSD) "-lthr"; 58 64 59 - makeFlags = "prefix=\${out} PERL_PATH=${perl}/bin/perl SHELL_PATH=${stdenv.shell} " 60 - + (if pythonSupport then "PYTHON_PATH=${python}/bin/python" else "NO_PYTHON=1") 61 - + (if stdenv.isSunOS then " INSTALL=install NO_INET_NTOP= NO_INET_PTON=" else "") 62 - + (if stdenv.isDarwin then " NO_APPLE_COMMON_CRYPTO=1" else " sysconfdir=/etc/ ") 63 - + (if stdenv.hostPlatform.isMusl then "NO_SYS_POLL_H=1 NO_GETTEXT=YesPlease" else ""); 65 + configureFlags = stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 66 + "ac_cv_fread_reads_directories=yes" 67 + "ac_cv_snprintf_returns_bogus=no" 68 + ]; 69 + 70 + makeFlags = [ 71 + "prefix=\${out}" 72 + "SHELL_PATH=${stdenv.shell}" 73 + ] 74 + ++ (if perlSupport then ["PERL_PATH=${perl}/bin/perl"] else ["NO_PERL=1"]) 75 + ++ (if pythonSupport then ["PYTHON_PATH=${python}/bin/python"] else ["NO_PYTHON=1"]) 76 + ++ stdenv.lib.optionals stdenv.isSunOS ["INSTALL=install" "NO_INET_NTOP=" "NO_INET_PTON="] 77 + ++ (if stdenv.isDarwin then ["NO_APPLE_COMMON_CRYPTO=1"] else ["sysconfdir=/etc/"]) 78 + ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl ["NO_SYS_POLL_H=1" "NO_GETTEXT=YesPlease"] 79 + ++ stdenv.lib.optional withpcre2 "USE_LIBPCRE2=1"; 64 80 65 81 # build git-credential-osxkeychain if darwin 66 82 postBuild = stdenv.lib.optionalString stdenv.isDarwin '' ··· 73 89 # so that `SPARSE_FLAGS' corresponds to the current architecture... 74 90 #doCheck = true; 75 91 76 - installFlags = "NO_INSTALL_HARDLINKS=1" 77 - + (if withpcre2 then " USE_LIBPCRE2=1" else ""); 78 - 92 + installFlags = "NO_INSTALL_HARDLINKS=1"; 79 93 80 94 preInstall = stdenv.lib.optionalString stdenv.isDarwin '' 81 95 mkdir -p $out/bin ··· 115 129 SCRIPT="$(cat <<'EOS' 116 130 BEGIN{ 117 131 @a=( 118 - '${perl}/bin/perl', '${gnugrep}/bin/grep', '${gnused}/bin/sed', '${gawk}/bin/awk', 132 + '${gnugrep}/bin/grep', '${gnused}/bin/sed', '${gawk}/bin/awk', 119 133 '${coreutils}/bin/cut', '${coreutils}/bin/basename', '${coreutils}/bin/dirname', 120 134 '${coreutils}/bin/wc', '${coreutils}/bin/tr' 135 + ${stdenv.lib.optionalString perlSupport ", '${perl}/bin/perl'"} 121 136 ); 122 137 } 123 138 foreach $c (@a) { ··· 133 148 substituteInPlace $out/libexec/git-core/git-sh-i18n \ 134 149 --subst-var-by gettext ${gettext} 135 150 136 - # put in separate package for simpler maintenance 137 - mv $out/share/gitweb $gitweb/ 138 - 139 151 # Also put git-http-backend into $PATH, so that we can use smart 140 152 # HTTP(s) transports for pushing 141 153 ln -s $out/libexec/git-core/git-http-backend $out/bin/git-http-backend 154 + '' + stdenv.lib.optionalString perlSupport '' 155 + # put in separate package for simpler maintenance 156 + mv $out/share/gitweb $gitweb/ 142 157 143 158 # wrap perl commands 144 159 gitperllib=$out/lib/perl5/site_perl ··· 184 199 '') 185 200 186 201 + stdenv.lib.optionalString withManual ''# Install man pages and Info manual 187 - make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES PERL_PATH="${perl}/bin/perl" cmd-list.made install install-info \ 202 + make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES cmd-list.made install install-info \ 188 203 -C Documentation '' 189 204 190 205 + (if guiSupport then ''