about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/perl
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-04-22 21:15:06 +0000
committerAlyssa Ross <hi@alyssa.is>2019-04-22 21:18:23 +0000
commitb935ae5f3cfb2bb4f9a3746d284f156a6dece505 (patch)
tree5efe4e2e7a7723a737d0130a333b057c5e76df40 /nixpkgs/pkgs/development/interpreters/perl
parentdc9566e91c9453378c24e98b5737234364670df5 (diff)
parentd26027792812fbfad4d0f451b5f47fdabf7fdeb9 (diff)
downloadnixlib-b935ae5f3cfb2bb4f9a3746d284f156a6dece505.tar
nixlib-b935ae5f3cfb2bb4f9a3746d284f156a6dece505.tar.gz
nixlib-b935ae5f3cfb2bb4f9a3746d284f156a6dece505.tar.bz2
nixlib-b935ae5f3cfb2bb4f9a3746d284f156a6dece505.tar.lz
nixlib-b935ae5f3cfb2bb4f9a3746d284f156a6dece505.tar.xz
nixlib-b935ae5f3cfb2bb4f9a3746d284f156a6dece505.tar.zst
nixlib-b935ae5f3cfb2bb4f9a3746d284f156a6dece505.zip
Merge commit 'd26027792812fbfad4d0f451b5f47fdabf7fdeb9'
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/perl')
-rw-r--r--nixpkgs/pkgs/development/interpreters/perl/default.nix21
-rw-r--r--nixpkgs/pkgs/development/interpreters/perl/wrapper.nix55
2 files changed, 73 insertions, 3 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/perl/default.nix b/nixpkgs/pkgs/development/interpreters/perl/default.nix
index 9adc72f941a2..e03777b0fb35 100644
--- a/nixpkgs/pkgs/development/interpreters/perl/default.nix
+++ b/nixpkgs/pkgs/development/interpreters/perl/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchurl, buildPackages
+{ config, lib, stdenv, fetchurl, buildPackages, callPackage
 , enableThreading ? stdenv ? glibc, makeWrapper
 }:
 
@@ -22,7 +22,8 @@ let
   libcInc = lib.getDev libc;
   libcLib = lib.getLib libc;
   crossCompiling = stdenv.buildPlatform != stdenv.hostPlatform;
-  common = { version, sha256 }: stdenv.mkDerivation (rec {
+
+  common = { self, version, sha256 }: stdenv.mkDerivation (rec {
     inherit version;
 
     name = "perl-${version}";
@@ -104,7 +105,19 @@ let
 
     setupHook = ./setup-hook.sh;
 
-    passthru.libPrefix = "lib/perl5/site_perl";
+    passthru = rec {
+      interpreter = "${self}/bin/perl";
+      libPrefix = "lib/perl5/site_perl";
+      pkgs = callPackage ../../../top-level/perl-packages.nix {
+        perl = self;
+        overrides = config.perlPackageOverrides or (p: {}); # TODO: (self: super: {}) like in python
+      };
+      buildEnv = callPackage ./wrapper.nix {
+        perl = self;
+        inherit (pkgs) requiredPerlModules;
+      };
+      withPackages = f: buildEnv.override { extraLibs = f pkgs; };
+    };
 
     doCheck = false; # some tests fail, expensive
 
@@ -179,12 +192,14 @@ let
 in rec {
   # the latest Maint version
   perl528 = common {
+    self = perl528;
     version = "5.28.1";
     sha256 = "0iy3as4hnbjfyws4in3j9d6zhhjxgl5m95i5n9jy2bnzcpz8bgry";
   };
 
   # the latest Devel version
   perldevel = common {
+    self = perldevel;
     version = "5.29.9";
     sha256 = "017x3nghyc5m8q1yqnrdma96b3d5rlfx87vv5mi64jq0r8k6zppm";
   };
diff --git a/nixpkgs/pkgs/development/interpreters/perl/wrapper.nix b/nixpkgs/pkgs/development/interpreters/perl/wrapper.nix
new file mode 100644
index 000000000000..9142a1f4fc36
--- /dev/null
+++ b/nixpkgs/pkgs/development/interpreters/perl/wrapper.nix
@@ -0,0 +1,55 @@
+{ stdenv, perl, buildEnv, makeWrapper
+, extraLibs ? []
+, extraOutputsToInstall ? []
+, postBuild ? ""
+, ignoreCollisions ? false
+, lib
+, requiredPerlModules
+, makeWrapperArgs ? []
+}:
+
+# Create a perl executable that knows about additional packages.
+let
+  env = let
+    paths = requiredPerlModules (extraLibs ++ [ perl ] );
+  in buildEnv {
+    name = "${perl.name}-env";
+
+    inherit paths;
+    inherit ignoreCollisions;
+    extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
+
+    # we create wrapper for the binaries in the different packages
+    postBuild = ''
+
+      . "${makeWrapper}/nix-support/setup-hook"
+
+      if [ -L "$out/bin" ]; then
+          unlink "$out/bin"
+      fi
+      mkdir -p "$out/bin"
+
+      # take every binary from perl packages and put them into the env
+      for path in ${stdenv.lib.concatStringsSep " " paths}; do
+        if [ -d "$path/bin" ]; then
+          cd "$path/bin"
+          for prg in *; do
+            if [ -f "$prg" ]; then
+              rm -f "$out/bin/$prg"
+              if [ -x "$prg" ]; then
+                makeWrapper "$path/bin/$prg" "$out/bin/$prg" --set PERL5LIB "$out/${perl.libPrefix}"
+              fi
+            fi
+          done
+        fi
+      done
+    '' + postBuild;
+
+    meta = perl.meta // { outputsToInstall = ["out"]; }; # remove "man" from meta.outputsToInstall. pkgs.buildEnv produces no "man", it puts everything to "out"
+
+    passthru = perl.passthru // {
+      interpreter = "${env}/bin/perl";
+      inherit perl;
+    };
+  };
+in env