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/
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{lib, stdenv, which, coreutils, perl, fetchurl, perlPackages, makeWrapper, diffutils , writeScriptBin, bzip2}:
|
||||
{lib, stdenv, which, coreutils, perl, fetchurl, makeWrapper, diffutils , writeScriptBin, bzip2}:
|
||||
|
||||
# quick usage:
|
||||
# storeBackup.pl --sourceDir /home/user --backupDir /tmp/my_backup_destination
|
||||
@@ -37,12 +37,10 @@ stdenv.mkDerivation rec {
|
||||
find $out -name "*.pl" | xargs sed -i \
|
||||
-e 's@/bin/pwd@${coreutils}/bin/pwd@' \
|
||||
-e 's@/bin/sync@${coreutils}/bin/sync@' \
|
||||
-e '1 s@/usr/bin/env perl@${perl}/bin/perl@'
|
||||
-e '1 s@/usr/bin/env perl@${perl.withPackages (p: [ p.DBFile ])}/bin/perl@'
|
||||
|
||||
for p in $out/bin/*
|
||||
do wrapProgram "$p" \
|
||||
--prefix PERL5LIB ":" "${perlPackages.DBFile}/${perlPackages.perl.libPrefix}" \
|
||||
--prefix PATH ":" "${lib.makeBinPath [ which bzip2 ]}"
|
||||
do wrapProgram "$p" --prefix PATH ":" "${lib.makeBinPath [ which bzip2 ]}"
|
||||
done
|
||||
|
||||
patchShebangs $out
|
||||
|
||||
@@ -21,6 +21,11 @@ let
|
||||
propagatedBuildInputs = [ perlPackages.IOPipely Mojolicious-8-35 ];
|
||||
};
|
||||
|
||||
perl' = perl.withPackages (p:
|
||||
[ MojoIOLoopForkCall-0-20
|
||||
p.TAPParserSourceHandlerpgTAP
|
||||
]);
|
||||
|
||||
version = "0.20.0";
|
||||
checksum = "15lb5qwksa508m9bj6d3n4rrjpakfaas9qxspg408bcqfp7pqjw3";
|
||||
in
|
||||
@@ -35,7 +40,7 @@ stdenv.mkDerivation {
|
||||
sha256 = checksum;
|
||||
};
|
||||
|
||||
buildInputs = [ wget perl MojoIOLoopForkCall-0-20 perlPackages.TAPParserSourceHandlerpgTAP ];
|
||||
buildInputs = [ wget perl' ];
|
||||
|
||||
nativeBuildInputs = [ autoconf automake autoreconfHook ];
|
||||
|
||||
@@ -53,30 +58,6 @@ stdenv.mkDerivation {
|
||||
automake
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
substituteInPlace $out/bin/znapzend --replace "${perl}/bin/perl" \
|
||||
"${perl}/bin/perl \
|
||||
-I${Mojolicious-8-35}/${perl.libPrefix} \
|
||||
-I${perlPackages.TAPParserSourceHandlerpgTAP}/${perl.libPrefix} \
|
||||
-I${MojoIOLoopForkCall-0-20}/${perl.libPrefix} \
|
||||
-I${perlPackages.IOPipely}/${perl.libPrefix} \
|
||||
"
|
||||
substituteInPlace $out/bin/znapzendzetup --replace "${perl}/bin/perl" \
|
||||
"${perl}/bin/perl \
|
||||
-I${Mojolicious-8-35}/${perl.libPrefix} \
|
||||
-I${perlPackages.TAPParserSourceHandlerpgTAP}/${perl.libPrefix} \
|
||||
-I${MojoIOLoopForkCall-0-20}/${perl.libPrefix} \
|
||||
-I${perlPackages.IOPipely}/${perl.libPrefix} \
|
||||
"
|
||||
substituteInPlace $out/bin/znapzendztatz --replace "${perl}/bin/perl" \
|
||||
"${perl}/bin/perl \
|
||||
-I${Mojolicious-8-35}/${perl.libPrefix} \
|
||||
-I${perlPackages.TAPParserSourceHandlerpgTAP}/${perl.libPrefix} \
|
||||
-I${MojoIOLoopForkCall-0-20}/${perl.libPrefix} \
|
||||
-I${perlPackages.IOPipely}/${perl.libPrefix} \
|
||||
"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "High performance open source ZFS backup with mbuffer and ssh support";
|
||||
homepage = "http://www.znapzend.org";
|
||||
|
||||
Reference in New Issue
Block a user