about summary refs log tree commit diff
path: root/pkgs/top-level/perl-packages.nix
diff options
context:
space:
mode:
authorMichael Eden <themichaeleden@gmail.com>2019-02-18 17:31:59 -0500
committerMichael Eden <themichaeleden@gmail.com>2019-02-18 17:31:59 -0500
commit33ef2829b663945d0d7ae702a6f5f5f342760401 (patch)
tree5c4807f4fc64f6090c68cef7460cd4377c12a6db /pkgs/top-level/perl-packages.nix
parentf7c6e6bbe3c325d7dcb56ff4b3356c40c8866c82 (diff)
downloadnixlib-33ef2829b663945d0d7ae702a6f5f5f342760401.tar
nixlib-33ef2829b663945d0d7ae702a6f5f5f342760401.tar.gz
nixlib-33ef2829b663945d0d7ae702a6f5f5f342760401.tar.bz2
nixlib-33ef2829b663945d0d7ae702a6f5f5f342760401.tar.lz
nixlib-33ef2829b663945d0d7ae702a6f5f5f342760401.tar.xz
nixlib-33ef2829b663945d0d7ae702a6f5f5f342760401.tar.zst
nixlib-33ef2829b663945d0d7ae702a6f5f5f342760401.zip
perlPackages.TermReadKey: add workarounds for cross compilation
Diffstat (limited to 'pkgs/top-level/perl-packages.nix')
-rw-r--r--pkgs/top-level/perl-packages.nix19
1 files changed, 18 insertions, 1 deletions
diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix
index 2866f6b6ca5f..5b74b0a3ee26 100644
--- a/pkgs/top-level/perl-packages.nix
+++ b/pkgs/top-level/perl-packages.nix
@@ -5,7 +5,8 @@
    for each package in a separate file: the call to the function would
    be almost as much code as the function itself. */
 
-{config, pkgs, fetchurl, fetchFromGitHub, stdenv, gnused, perl, overrides}:
+{config, pkgs, fetchurl, fetchFromGitHub, stdenv, gnused, perl, overrides,
+  buildPackages}:
 
 # cpan2nix assumes that perl-packages.nix will be used only with perl 5.28.1 or above
 assert stdenv.lib.versionAtLeast perl.version "5.28.1";
@@ -14587,6 +14588,22 @@ let
       url = "mirror://cpan/authors/id/J/JS/JSTOWE/${name}.tar.gz";
       sha256 = "0hdj5mldpj3pyprd4hbbalfx9yjgi5p59gg2ixk9808f5v7q74sa";
     };
+    cross = stdenv.hostPlatform != stdenv.buildPlatform;
+
+    # use native libraries from the host when running build commands
+    postConfigure = if cross then let
+      host_perl = buildPackages.perl;
+      host_self = buildPackages.perlPackages.TermReadKey;
+      perl_lib = "${host_perl}/lib/perl5/${host_perl.version}";
+      self_lib = "${host_self}/lib/perl5/site_perl/${host_perl.version}";
+    in ''
+      sed -ie 's|"-I$(INST_ARCHLIB)"|"-I${perl_lib}" "-I${self_lib}"|g' Makefile
+    '' else null;
+
+    # TermReadKey uses itself in the build process
+    nativeBuildInputs = if cross then [
+      buildPackages.perlPackages.TermReadKey
+    ] else [];
   };
 
   TermReadLineGnu = buildPerlPackage rec {