Perl: Difference between revisions

imported>Nix
→‎Invoking nix-shell on command-line: fix nix-shell commandline example
m ryantm link -> canonical Nixpkgs manual
 
(5 intermediate revisions by 4 users not shown)
Line 55: Line 55:
==Adding something from CPAN to nixpkgs==
==Adding something from CPAN to nixpkgs==


* Use the <tt>nix-generate-from-cpan.pl</tt> script (see <tt>nixpkgs/maintainers/scripts/</tt>) to generate something appropriate.<br/>Example usage: <tt>nix-generate-from-cpan.pl Devel::REPL</tt>
# Enter a <tt>nix-shell</tt> that provides the necessary dependencies: <syntaxHighlight lang=shell>nix-shell -p perl perlPackages.CPANPLUS perlPackages.GetoptLongDescriptive perlPackages.LogLog4perl perlPackages.Readonly</syntaxHighlight>.
* After reviewing the result from the previous step and making appropriate modifications, add it to <code>pkgs/top-level/perl-packages.nix</code>.  Note that some things use <code>buildPerlPackage</code> while some use <code>buildPerlModule</code>.  Also note the mostly-followed naming convention as well as the mostly-followed alphabetical ordering. There are plenty of examples in <tt>perl-packages.nix</tt> &mdash; use the source, Luke!
# Use the <tt>nix-generate-from-cpan.pl</tt> script (see <tt>nixpkgs/maintainers/scripts/</tt>) to generate something appropriate.<br/>Example usage: <syntaxHighlight lang=shell>nix-generate-from-cpan.pl Devel::REPL</syntaxHighlight>
* Build and test.
# After reviewing the result from the previous step and making appropriate modifications, add it to <code>pkgs/top-level/perl-packages.nix</code>.  Note that some things use <code>buildPerlPackage</code> while some use <code>buildPerlModule</code>.  Also note the mostly-followed naming convention as well as the mostly-followed alphabetical ordering. There are plenty of examples in <tt>perl-packages.nix</tt> &mdash; use the source, Luke!
# Build and test.


==Wrappers for installed programs==
==Wrappers for installed programs==


To make perl modules available to a program in your derivation:
To make perl modules available to a program in your derivation:
* add <code>makeWrapper</code> to <code>nativeBuildInputs</code>
# Add <code>makeWrapper</code> to <code>nativeBuildInputs</code>
* add <syntaxhighlight lang="nix">
# Add <syntaxhighlight lang="nix">
postFixup = ''
postFixup = ''
   wrapProgram $out/bin/something \
   wrapProgram $out/bin/something \
Line 69: Line 70:
'';
'';
</syntaxhighlight>
</syntaxhighlight>
 
Also keep in mind that <code>makePerlPath</code> would not resolve transitive dependencies of Perl packages. Hence if you want to just reference top-level packages, then use <code>makeFullPerlPath</code> which would recursively resolve dependency graph for you.
== See also ==
== See also ==
* [https://nixos.org/manual/nixpkgs/unstable/#sec-language-perl Nixpkgs Manual - Perl section]
* [https://nixos.org/manual/nixpkgs/stable/#sec-language-perl Nixpkgs Manual - Perl section]
* [https://blog.stigok.com/2020/04/15/building-a-custom-perl-package-for-nixos.html Building a custom Perl package in NixOS]
* [https://blog.stigok.com/2020/04/16/building-a-custom-perl-package-for-nixos.html Overriding an existing Perl package in NixOS]
 
[[Category:Languages]]
[[Category:Languages]]