diff options
author | rnhmjoj <rnhmjoj@inventati.org> | 2021-02-24 20:53:45 +0100 |
---|---|---|
committer | rnhmjoj <rnhmjoj@inventati.org> | 2021-03-31 21:35:37 +0200 |
commit | 61b7cab4811e0e90937bcc8b4c1ca32b387c895c (patch) | |
tree | db5dc9f491f86fe61dc23dcf042ea6eed08327aa /pkgs/tools | |
parent | 3966039910db296c1c2dca2120ab0976952fe11c (diff) |
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/
Diffstat (limited to 'pkgs/tools')
-rw-r--r-- | pkgs/tools/backup/store-backup/default.nix | 8 | ||||
-rw-r--r-- | pkgs/tools/backup/znapzend/default.nix | 31 | ||||
-rw-r--r-- | pkgs/tools/filesystems/file-rename/default.nix | 10 | ||||
-rw-r--r-- | pkgs/tools/misc/lbdb/default.nix | 37 | ||||
-rw-r--r-- | pkgs/tools/networking/tgt/default.nix | 4 | ||||
-rw-r--r-- | pkgs/tools/package-management/dpkg/default.nix | 3 | ||||
-rw-r--r-- | pkgs/tools/virtualization/nixos-container/default.nix | 4 | ||||
-rwxr-xr-x | pkgs/tools/virtualization/nixos-container/nixos-container.pl | 2 |
8 files changed, 36 insertions, 63 deletions
diff --git a/pkgs/tools/backup/store-backup/default.nix b/pkgs/tools/backup/store-backup/default.nix index 026a3141fedee..afa667ec07251 100644 --- a/pkgs/tools/backup/store-backup/default.nix +++ b/pkgs/tools/backup/store-backup/default.nix @@ -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 diff --git a/pkgs/tools/backup/znapzend/default.nix b/pkgs/tools/backup/znapzend/default.nix index 1e4e84b445bd1..9c3e4fca95deb 100644 --- a/pkgs/tools/backup/znapzend/default.nix +++ b/pkgs/tools/backup/znapzend/default.nix @@ -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"; diff --git a/pkgs/tools/filesystems/file-rename/default.nix b/pkgs/tools/filesystems/file-rename/default.nix index 6ddf5d7886335..133f446f8a98f 100644 --- a/pkgs/tools/filesystems/file-rename/default.nix +++ b/pkgs/tools/filesystems/file-rename/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, perlPackages, makeWrapper }: +{ lib, stdenv, fetchurl, perl, perlPackages }: perlPackages.buildPerlPackage { pname = "File-Rename"; @@ -9,17 +9,15 @@ perlPackages.buildPerlPackage { sha256 = "1cf6xx2hiy1xalp35fh8g73j67r0w0g66jpcbc6971x9jbm7bvjy"; }; - nativeBuildInputs = [ makeWrapper ]; - # Fix an incorrect platform test that misidentifies Darwin as Windows postPatch = '' substituteInPlace Makefile.PL \ --replace '/win/i' '/MSWin32/' ''; - postInstall = '' - wrapProgram $out/bin/rename \ - --prefix PERL5LIB : $out/${perlPackages.perl.libPrefix} + postFixup = '' + substituteInPlace $out/bin/rename \ + --replace "#!${perl}/bin/perl" "#!${perl}/bin/perl -I $out/${perl.libPrefix}" ''; doCheck = !stdenv.isDarwin; diff --git a/pkgs/tools/misc/lbdb/default.nix b/pkgs/tools/misc/lbdb/default.nix index fd8b805743aca..ea4b2a9cbbc52 100644 --- a/pkgs/tools/misc/lbdb/default.nix +++ b/pkgs/tools/misc/lbdb/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, fetchpatch, perl, perlPackages, finger_bsd, makeWrapper +{ lib, stdenv, fetchurl, fetchpatch, perl, finger_bsd , abook ? null , gnupg ? null , goobook ? null @@ -8,9 +8,8 @@ let version = "0.48.1"; + perl' = perl.withPackages (p: with p; [ ConvertASN1 perlldap AuthenSASL ]); in -with lib; -with perlPackages; stdenv.mkDerivation { pname = "lbdb"; inherit version; @@ -19,20 +18,20 @@ stdenv.mkDerivation { sha256 = "1gr5l2fr9qbdccga8bhsrpvz6jxigvfkdxrln9wyf2xpps5cdjxh"; }; - nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ goobook perl ConvertASN1 perlldap AuthenSASL ] - ++ optional (!stdenv.isDarwin) finger_bsd - ++ optional (abook != null) abook - ++ optional (gnupg != null) gnupg - ++ optional (goobook != null) goobook - ++ optional (khard != null) khard - ++ optional (mu != null) mu; + buildInputs = [ goobook perl' ] + ++ lib.optional (!stdenv.isDarwin) finger_bsd + ++ lib.optional (abook != null) abook + ++ lib.optional (gnupg != null) gnupg + ++ lib.optional (goobook != null) goobook + ++ lib.optional (khard != null) khard + ++ lib.optional (mu != null) mu; + configureFlags = [ ] - ++ optional (abook != null) "--with-abook" - ++ optional (gnupg != null) "--with-gpg" - ++ optional (goobook != null) "--with-goobook" - ++ optional (khard != null) "--with-khard" - ++ optional (mu != null) "--with-mu"; + ++ lib.optional (abook != null) "--with-abook" + ++ lib.optional (gnupg != null) "--with-gpg" + ++ lib.optional (goobook != null) "--with-goobook" + ++ lib.optional (khard != null) "--with-khard" + ++ lib.optional (mu != null) "--with-mu"; patches = [ ./add-methods-to-rc.patch # fix undefined exec_prefix. Remove with the next release @@ -42,12 +41,8 @@ stdenv.mkDerivation { excludes = [ "debian/changelog" ]; }) ]; - postFixup = "wrapProgram $out/lib/mutt_ldap_query --prefix PERL5LIB : " - + "${AuthenSASL}/${perl.libPrefix}" - + ":${ConvertASN1}/${perl.libPrefix}" - + ":${perlldap}/${perl.libPrefix}"; - meta = { + meta = with lib; { homepage = "https://www.spinnaker.de/lbdb/"; license = licenses.gpl2; platforms = platforms.all; diff --git a/pkgs/tools/networking/tgt/default.nix b/pkgs/tools/networking/tgt/default.nix index ca40f9a7cb70c..ba1f89af433e0 100644 --- a/pkgs/tools/networking/tgt/default.nix +++ b/pkgs/tools/networking/tgt/default.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchFromGitHub, libxslt, libaio, systemd, perl, perlPackages +{ stdenv, lib, fetchFromGitHub, libxslt, libaio, systemd, perl , docbook_xsl, coreutils, lsof, rdma-core, makeWrapper, sg3_utils, util-linux }: @@ -35,7 +35,7 @@ stdenv.mkDerivation rec { postInstall = '' substituteInPlace $out/sbin/tgt-admin \ - --replace "#!/usr/bin/perl" "#! ${perl}/bin/perl -I${perlPackages.ConfigGeneral}/${perl.libPrefix}" + --replace "#!/usr/bin/perl" "#! ${perl.withPackages (p: [ p.ConfigGeneral ])}/bin/perl" wrapProgram $out/sbin/tgt-admin --prefix PATH : \ ${lib.makeBinPath [ lsof sg3_utils (placeholder "out") ]} 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 diff --git a/pkgs/tools/virtualization/nixos-container/default.nix b/pkgs/tools/virtualization/nixos-container/default.nix index badd25b4e248a..17065a2aa8b95 100644 --- a/pkgs/tools/virtualization/nixos-container/default.nix +++ b/pkgs/tools/virtualization/nixos-container/default.nix @@ -1,11 +1,11 @@ -{ substituteAll, perlPackages, shadow, util-linux }: +{ substituteAll, perl, shadow, util-linux }: substituteAll { name = "nixos-container"; dir = "bin"; isExecutable = true; src = ./nixos-container.pl; - perl = "${perlPackages.perl}/bin/perl -I${perlPackages.FileSlurp}/${perlPackages.perl.libPrefix}"; + perl = perl.withPackages (p: [ p.FileSlurp ]); su = "${shadow.su}/bin/su"; utillinux = util-linux; diff --git a/pkgs/tools/virtualization/nixos-container/nixos-container.pl b/pkgs/tools/virtualization/nixos-container/nixos-container.pl index b399b3d69174d..d99b4cfba4a3e 100755 --- a/pkgs/tools/virtualization/nixos-container/nixos-container.pl +++ b/pkgs/tools/virtualization/nixos-container/nixos-container.pl @@ -1,4 +1,4 @@ -#! @perl@ +#! @perl@/bin/perl use strict; use POSIX; |