summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/default.nix2
-rw-r--r--lib/strings.nix16
-rw-r--r--pkgs/top-level/perl-packages.nix8
3 files changed, 17 insertions, 9 deletions
diff --git a/lib/default.nix b/lib/default.nix
index c1a4a1e39a81..dd6fcec75e21 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -80,7 +80,7 @@ let
     inherit (strings) concatStrings concatMapStrings concatImapStrings
       intersperse concatStringsSep concatMapStringsSep
       concatImapStringsSep makeSearchPath makeSearchPathOutput
-      makeLibraryPath makeBinPath makePerlPath optionalString
+      makeLibraryPath makeBinPath makePerlPath makeFullPerlPath optionalString
       hasPrefix hasSuffix stringToCharacters stringAsChars escape
       escapeShellArg escapeShellArgs replaceChars lowerChars
       upperChars toLower toUpper addContextFrom splitString
diff --git a/lib/strings.nix b/lib/strings.nix
index 7cd09a109396..64b5e83ff9b4 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -126,6 +126,22 @@ rec {
   */
   makePerlPath = makeSearchPathOutput "lib" "lib/perl5/site_perl";
 
+  /* Construct a perl search path recursively including all dependencies (such as $PERL5LIB)
+
+     Example:
+       pkgs = import <nixpkgs> { }
+       makeFullPerlPath [ pkgs.perlPackages.CGI ]
+       => "/nix/store/fddivfrdc1xql02h9q500fpnqy12c74n-perl-CGI-4.38/lib/perl5/site_perl:/nix/store/8hsvdalmsxqkjg0c5ifigpf31vc4vsy2-perl-HTML-Parser-3.72/lib/perl5/site_perl:/nix/store/zhc7wh0xl8hz3y3f71nhlw1559iyvzld-perl-HTML-Tagset-3.20/lib/perl5/site_perl"
+  */
+  makeFullPerlPath = deps:
+    let
+      recurse = dep:
+        [ dep ] ++ dep.propagatedBuildInputs ++ (map (arg: recurse arg) dep.propagatedBuildInputs)
+      ;
+    in
+      makePerlPath (lib.unique (lib.flatten (map (arg: recurse arg) deps)))
+  ;
+
   /* Depending on the boolean `cond', return either the given string
      or the empty string. Useful to concatenate against a bigger string.
 
diff --git a/pkgs/top-level/perl-packages.nix b/pkgs/top-level/perl-packages.nix
index 51413009e685..7f09630debfc 100644
--- a/pkgs/top-level/perl-packages.nix
+++ b/pkgs/top-level/perl-packages.nix
@@ -28,14 +28,6 @@ let
       checkPhase = "./Build test";
     });
 
-  # Helper function to make a PERL5LIB environment variable for a list of perlPackages and all associated runtime dependencies
-  makePerl5Lib = deps:
-    with stdenv;
-    lib.concatStringsSep ":" [
-      (lib.makePerlPath deps)
-      (lib.concatStringsSep ":" (map (dep: dep + "/lib/perl5/site_perl") (builtins.filter (dep: dep != null) (lib.flatten (map (dep: lib.getOutput "propagatedBuildInputs" dep) deps)))))
-    ]
-  ;
 
   ack = buildPerlPackage rec {
     name = "ack-2.24";