mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-04 21:03:15 +00:00
61b7cab481
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/
31 lines
821 B
Nix
31 lines
821 B
Nix
{ lib, stdenv, fetchurl, perl, perlPackages }:
|
|
|
|
perlPackages.buildPerlPackage {
|
|
pname = "File-Rename";
|
|
version = "0.20";
|
|
|
|
src = fetchurl {
|
|
url = "mirror://cpan/authors/id/R/RM/RMBARKER/File-Rename-0.20.tar.gz";
|
|
sha256 = "1cf6xx2hiy1xalp35fh8g73j67r0w0g66jpcbc6971x9jbm7bvjy";
|
|
};
|
|
|
|
# Fix an incorrect platform test that misidentifies Darwin as Windows
|
|
postPatch = ''
|
|
substituteInPlace Makefile.PL \
|
|
--replace '/win/i' '/MSWin32/'
|
|
'';
|
|
|
|
postFixup = ''
|
|
substituteInPlace $out/bin/rename \
|
|
--replace "#!${perl}/bin/perl" "#!${perl}/bin/perl -I $out/${perl.libPrefix}"
|
|
'';
|
|
|
|
doCheck = !stdenv.isDarwin;
|
|
|
|
meta = with lib; {
|
|
description = "Perl extension for renaming multiple files";
|
|
license = licenses.artistic1;
|
|
maintainers = with maintainers; [ peterhoeg ];
|
|
};
|
|
}
|