Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perlPackages.TermReadKey: add workarounds for cross compilation #56019

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkgs/development/perl-modules/generic/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, perl }:
{ lib, stdenv, perl, buildPackages }:

{ nativeBuildInputs ? [], name, ... } @ attrs:

Expand Down Expand Up @@ -37,6 +37,6 @@ stdenv.mkDerivation (
name = "perl${perl.version}-${name}";
builder = ./builder.sh;
nativeBuildInputs = nativeBuildInputs ++ [ (perl.dev or perl) ];
inherit perl;
perl = buildPackages.perl;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used at the end of this line

perl Makefile.PL PREFIX=$out INSTALLDIRS=site $makeMakerFlags PERL=$(type -P perl) FULLPERL=\"$perl/bin/perl\"
to give perl's Makefile a version of perl that can be used on the build platform (during build time).

}
)
19 changes: 18 additions & 1 deletion pkgs/top-level/perl-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 {
Expand Down