From 61b7cab4811e0e90937bcc8b4c1ca32b387c895c Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 24 Feb 2021 20:53:45 +0100 Subject: treewide: use perl.withPackages when possible Since 03eaa48 added perl.withPackages, there is a canonical way to create a perl interpreter from a list of libraries, for use in script shebangs or generic build inputs. This method is declarative (what we are doing is clear), produces short shebangs[1] and needs not to wrap existing scripts. Unfortunately there are a few exceptions that I've found: 1. Scripts that are calling perl with the -T switch. This makes perl ignore PERL5LIB, which is what perl.withPackages is using to inform the interpreter of the library paths. 2. Perl packages that depends on libraries in their own path. This is not possible because perl.withPackages works at build time. The workaround is to add `-I $out/${perl.libPrefix}` to the shebang. In all other cases I propose to switch to perl.withPackages. [1]: https://lwn.net/Articles/779997/ --- pkgs/tools/package-management/dpkg/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkgs/tools/package-management/dpkg') diff --git a/pkgs/tools/package-management/dpkg/default.nix b/pkgs/tools/package-management/dpkg/default.nix index 459b9550b7c89..0026dd37ca439 100644 --- a/pkgs/tools/package-management/dpkg/default.nix +++ b/pkgs/tools/package-management/dpkg/default.nix @@ -56,7 +56,8 @@ stdenv.mkDerivation rec { '' for i in $out/bin/*; do if head -n 1 $i | grep -q perl; then - wrapProgram $i --prefix PERL5LIB : $out/${perl.libPrefix} + substituteInPlace $i --replace \ + "${perl}/bin/perl" "${perl}/bin/perl -I $out/${perl.libPrefix}" fi done -- cgit 1.4.1