about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2020-03-03 17:35:31 -0800
committerGitHub <noreply@github.com>2020-03-03 17:35:31 -0800
commitd881de1e9641735ef3fd6beffb1a6006140baf17 (patch)
treec9aea90f623813fb668368d31697a4484dff8cdb
parent9dc1cc507d5a9132b6e8f49b09c0190f462a58b7 (diff)
parent3b72c55fc5aff74cc7bdef1f15c04c29e5671ab1 (diff)
downloadnixlib-d881de1e9641735ef3fd6beffb1a6006140baf17.tar
nixlib-d881de1e9641735ef3fd6beffb1a6006140baf17.tar.gz
nixlib-d881de1e9641735ef3fd6beffb1a6006140baf17.tar.bz2
nixlib-d881de1e9641735ef3fd6beffb1a6006140baf17.tar.lz
nixlib-d881de1e9641735ef3fd6beffb1a6006140baf17.tar.xz
nixlib-d881de1e9641735ef3fd6beffb1a6006140baf17.tar.zst
nixlib-d881de1e9641735ef3fd6beffb1a6006140baf17.zip
Merge pull request #81317 from eamsden/eamsden/nix23-fix-cross-compile
nix: Patch config.nix.in to reference host platform binaries
-rw-r--r--pkgs/tools/package-management/nix/default.nix23
1 files changed, 19 insertions, 4 deletions
diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix
index eed14a129785..29af4a90cb90 100644
--- a/pkgs/tools/package-management/nix/default.nix
+++ b/pkgs/tools/package-management/nix/default.nix
@@ -10,6 +10,7 @@ let
 
 common =
   { lib, stdenv, fetchpatch, perl, curl, bzip2, sqlite, openssl ? null, xz
+  , bash, coreutils, gzip, gnutar
   , pkgconfig, boehmgc, perlPackages, libsodium, brotli, boost, editline, nlohmann_json
   , jq, libarchive, rustc, cargo
   , busybox-sandbox-shell
@@ -30,6 +31,7 @@ common =
 
       is20 = lib.versionAtLeast version "2.0pre";
       is24 = lib.versionAtLeast version "2.4pre";
+      isExactly23 = lib.versionAtLeast version "2.3" && lib.versionOlder version "2.4";
 
       VERSION_SUFFIX = suffix;
 
@@ -64,7 +66,7 @@ common =
       preConfigure =
         # Copy libboost_context so we don't get all of Boost in our closure.
         # https://github.com/NixOS/nixpkgs/issues/45462
-        if is20 then ''
+        lib.optionalString is20 ''
           mkdir -p $out/lib
           cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
           rm -f $out/lib/*.a
@@ -72,9 +74,21 @@ common =
             chmod u+w $out/lib/*.so.*
             patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
           ''}
-        '' else ''
-          configureFlagsArray+=(BDW_GC_LIBS="-lgc -lgccpp")
-        '';
+        '' +
+        # For Nix-2.3, patch around an issue where the Nix configure step pulls in the
+        # build system's bash and other utilities when cross-compiling
+        lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform && isExactly23) ''
+          mkdir tmp/
+          substitute corepkgs/config.nix.in tmp/config.nix.in \
+            --subst-var-by bash ${bash}/bin/bash \
+            --subst-var-by coreutils ${coreutils}/bin \
+            --subst-var-by bzip2 ${bzip2}/bin/bzip2 \
+            --subst-var-by gzip ${gzip}/bin/gzip \
+            --subst-var-by xz ${xz}/bin/xz \
+            --subst-var-by tar ${gnutar}/bin/tar \
+            --subst-var-by tr ${coreutils}/bin/tr
+          mv tmp/config.nix.in corepkgs/config.nix.in
+          '';
 
       configureFlags =
         [ "--with-store-dir=${storeDir}"
@@ -87,6 +101,7 @@ common =
           "--with-dbi=${perlPackages.DBI}/${perl.libPrefix}"
           "--with-dbd-sqlite=${perlPackages.DBDSQLite}/${perl.libPrefix}"
           "--with-www-curl=${perlPackages.WWWCurl}/${perl.libPrefix}"
+          "BDW_GC_LIBS=\"-lgc -lgccpp\""
         ] ++ lib.optionals (is20 && stdenv.isLinux) [
           "--with-sandbox-shell=${sh}/bin/busybox"
         ]