summaryrefslogtreecommitdiffstats
path: root/maintainers
diff options
context:
space:
mode:
authorRobert Helgesson <robert@rycee.net>2016-05-15 22:49:16 +0200
committerRobert Helgesson <robert@rycee.net>2016-05-18 20:39:44 +0200
commit7ca412a2fad51eb7f819f5954dbbb7d9bf978197 (patch)
treedd126b40cd86f9f720e14624ba5793ec22378052 /maintainers
parentbf9afccdfefeb4d7eddb43640cb6786492bf32bd (diff)
nix-generate-from-cpan: fix core module detection
This makes the detection of core modules a bit more robust by checking the module inclusion in a pure Perl interpreter. This ensures that any extra path in the `nix-generate-from-cpan` script's `PERL5LIB` does not affect the generated package expression.
Diffstat (limited to 'maintainers')
-rw-r--r--maintainers/scripts/nix-generate-from-cpan.nix3
-rwxr-xr-xmaintainers/scripts/nix-generate-from-cpan.pl14
2 files changed, 9 insertions, 8 deletions
diff --git a/maintainers/scripts/nix-generate-from-cpan.nix b/maintainers/scripts/nix-generate-from-cpan.nix
index 864fd4e83f62..82d9ad6077a2 100644
--- a/maintainers/scripts/nix-generate-from-cpan.nix
+++ b/maintainers/scripts/nix-generate-from-cpan.nix
@@ -1,7 +1,7 @@
{ stdenv, makeWrapper, perl, perlPackages }:
stdenv.mkDerivation {
- name = "nix-generate-from-cpan-2";
+ name = "nix-generate-from-cpan-3";
buildInputs = with perlPackages; [
makeWrapper perl CPANMeta GetoptLongDescriptive CPANPLUS Readonly Log4Perl
@@ -20,5 +20,6 @@ stdenv.mkDerivation {
meta = {
maintainers = with stdenv.lib.maintainers; [ eelco rycee ];
description = "Utility to generate a Nix expression for a Perl package from CPAN";
+ platforms = stdenv.lib.platforms.unix;
};
}
diff --git a/maintainers/scripts/nix-generate-from-cpan.pl b/maintainers/scripts/nix-generate-from-cpan.pl
index 73e13bfe09a6..942cba792efa 100755
--- a/maintainers/scripts/nix-generate-from-cpan.pl
+++ b/maintainers/scripts/nix-generate-from-cpan.pl
@@ -278,13 +278,13 @@ sub get_deps {
foreach my $n ( $deps->required_modules ) {
next if $n eq "perl";
- # Hacky way to figure out if this module is part of Perl.
- if ( $n !~ /^JSON/ && $n !~ /^YAML/ && $n !~ /^Module::Pluggable/ && $n !~ /^if$/ ) {
- eval "use $n;";
- if ( !$@ ) {
- DEBUG("skipping Perl-builtin module $n");
- next;
- }
+ # Figure out whether the module is a core module by attempting
+ # to `use` the module in a pure Perl interpreter and checking
+ # whether it succeeded. Note, $^X is a magic variable holding
+ # the path to the running Perl interpreter.
+ if ( system("env -i $^X -M$n -e1 >/dev/null 2>&1") == 0 ) {
+ DEBUG("skipping Perl-builtin module $n");
+ next;
}
my $pkg = module_to_pkg( $cb, $n );