diff options
Diffstat (limited to 'doc/languages-frameworks/perl.xml')
-rw-r--r-- | doc/languages-frameworks/perl.xml | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/doc/languages-frameworks/perl.xml b/doc/languages-frameworks/perl.xml index a675e66658630..065212a0e1807 100644 --- a/doc/languages-frameworks/perl.xml +++ b/doc/languages-frameworks/perl.xml @@ -47,13 +47,13 @@ foo = import ../path/to/foo.nix { in <filename>all-packages.nix</filename>. You can test building a Perl package as follows: <screen> -$ nix-build -A perlPackages.ClassC3 +<prompt>$ </prompt>nix-build -A perlPackages.ClassC3 </screen> <varname>buildPerlPackage</varname> adds <literal>perl-</literal> to the start of the name attribute, so the package above is actually called <literal>perl-Class-C3-0.21</literal>. So to install it, you can say: <screen> -$ nix-env -i perl-Class-C3 +<prompt>$ </prompt>nix-env -i perl-Class-C3 </screen> (Of course you can also install using the attribute name: <literal>nix-env -i -A perlPackages.ClassC3</literal>.) @@ -75,7 +75,8 @@ $ nix-env -i perl-Class-C3 It adds the contents of the <envar>PERL5LIB</envar> environment variable to <literal>#! .../bin/perl</literal> line of Perl scripts as <literal>-I<replaceable>dir</replaceable></literal> flags. This ensures - that a script can find its dependencies. + that a script can find its dependencies. (This can cause this shebang line + to become too long for Darwin to handle; see the note below.) </para> </listitem> <listitem> @@ -137,6 +138,36 @@ ClassC3Componentised = buildPerlPackage rec { </programlisting> </para> + <para> + On Darwin, if a script has too many + <literal>-I<replaceable>dir</replaceable></literal> flags in its first line + (its “shebang line”), it will not run. This can be worked around by calling + the <literal>shortenPerlShebang</literal> function from the + <literal>postInstall</literal> phase: +<programlisting> +{ stdenv, buildPerlPackage, fetchurl, shortenPerlShebang }: + +ImageExifTool = buildPerlPackage { + pname = "Image-ExifTool"; + version = "11.50"; + + src = fetchurl { + url = "https://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-11.50.tar.gz"; + sha256 = "0d8v48y94z8maxkmw1rv7v9m0jg2dc8xbp581njb6yhr7abwqdv3"; + }; + + buildInputs = stdenv.lib.optional stdenv.isDarwin shortenPerlShebang; + postInstall = stdenv.lib.optional stdenv.isDarwin '' + shortenPerlShebang $out/bin/exiftool + ''; +}; +</programlisting> + This will remove the <literal>-I</literal> flags from the shebang line, + rewrite them in the <literal>use lib</literal> form, and put them on the next + line instead. This function can be given any number of Perl scripts as + arguments; it will modify them in-place. + </para> + <section xml:id="ssec-generation-from-CPAN"> <title>Generation from CPAN</title> @@ -148,7 +179,7 @@ ClassC3Componentised = buildPerlPackage rec { </para> <screen> -$ nix-env -i nix-generate-from-cpan +<prompt>$ </prompt>nix-env -i nix-generate-from-cpan </screen> <para> @@ -156,7 +187,7 @@ $ nix-env -i nix-generate-from-cpan unpacks the corresponding package, and prints a Nix expression on standard output. For example: <screen> -$ nix-generate-from-cpan XML::Simple +<prompt>$ </prompt>nix-generate-from-cpan XML::Simple XMLSimple = buildPerlPackage rec { name = "XML-Simple-2.22"; src = fetchurl { |