summary refs log tree commit diff
path: root/pkgs/tools/package-management
diff options
context:
space:
mode:
authorEdward Amsden <edward@blackriversoft.com>2020-03-02 07:04:31 -0500
committerEdward Amsden <edward@blackriversoft.com>2020-03-03 18:07:09 -0500
commitf1415f633cb5cca0000dc5d5b36b717a1b11ae0f (patch)
tree914f84b54388a7273087655d9a49bce4c6484b7b /pkgs/tools/package-management
parent695c1339b8a962871bb646eae4ff5cd79e5d6814 (diff)
downloadnixpkgs-f1415f633cb5cca0000dc5d5b36b717a1b11ae0f.tar
nixpkgs-f1415f633cb5cca0000dc5d5b36b717a1b11ae0f.tar.gz
nixpkgs-f1415f633cb5cca0000dc5d5b36b717a1b11ae0f.tar.bz2
nixpkgs-f1415f633cb5cca0000dc5d5b36b717a1b11ae0f.tar.lz
nixpkgs-f1415f633cb5cca0000dc5d5b36b717a1b11ae0f.tar.xz
nixpkgs-f1415f633cb5cca0000dc5d5b36b717a1b11ae0f.tar.zst
nixpkgs-f1415f633cb5cca0000dc5d5b36b717a1b11ae0f.zip
nix: Patch config.nix.in to reference host platform binaries
Diffstat (limited to 'pkgs/tools/package-management')
-rw-r--r--pkgs/tools/package-management/nix/default.nix38
1 files changed, 27 insertions, 11 deletions
diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix
index eed14a12978..a17a621fbbe 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,17 +66,31 @@ 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 ''
-          mkdir -p $out/lib
-          cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
-          rm -f $out/lib/*.a
-          ${lib.optionalString stdenv.isLinux ''
-            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")
-        '';
+        (if is20 then ''
+           mkdir -p $out/lib
+           cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
+           rm -f $out/lib/*.a
+           ${lib.optionalString stdenv.isLinux ''
+             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}"