From 034248f57a17c2db02f8bc2656c8d5ba446e4537 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 18 Apr 2009 11:09:24 +0000 Subject: [PATCH] * Document the generic Perl builder. svn path=/nixpkgs/trunk/; revision=15124 --- doc/language-support.xml | 166 +++++++++++++++++++++++++++++++++++++++ doc/manual.xml | 36 +-------- 2 files changed, 167 insertions(+), 35 deletions(-) create mode 100644 doc/language-support.xml diff --git a/doc/language-support.xml b/doc/language-support.xml new file mode 100644 index 00000000000..f5e7e74c123 --- /dev/null +++ b/doc/language-support.xml @@ -0,0 +1,166 @@ + + +Support for specific programming languages + +The standard build +environment makes it easy to build typical Autotools-based +packages with very little code. Any other kind of package can be +accomodated by overriding the appropriate phases of +stdenv. However, there are specialised functions +in Nixpkgs to easily build packages for other programming languages, +such as Perl or Haskell. These are described in this chapter. + + +
Perl + +Nixpkgs provides a function buildPerlPackage, +a generic package builder function for any Perl package that has a +standard Makefile.PL. It’s implemented in pkgs/development/perl-modules/generic. + +Most Perl packages from CPAN are so straight-forward to build +that they are defined in pkgs/all-packages.nix +itself. Here is an example: + + +perlClassC3 = buildPerlPackage rec { + name = "Class-C3-0.21"; + src = fetchurl { + url = "mirror://cpan/authors/id/F/FL/FLORA/${name}.tar.gz"; + sha256 = "1bl8z095y4js66pwxnm7s853pi9czala4sqc743fdlnk27kq94gz"; + }; +}; + + +Note the use of mirror://cpan/, and the +${name} in the URL definition to ensure that the +name attribute is consistent with the source that we’re actually +downloading. As usual, you can test this package as follows: + + +$ nix-build -A perlClassC3 + + +buildPerlPackage adds perl- to +the start of the name attribute, so the package above is actually +called perl-Class-C3-0.21. So to install it, you +can say: + + +$ nix-env -i perl-Class-C3 + + +(Of course you can also install using the attribute name: +nix-env -i -A perlClassC3.) + +So what does buildPerlPackage do? It does +the following: + + + + In the configure phase, it calls perl + Makefile.PL to generate a Makefile. You can set the + variable makeMakerFlags to pass flags to + Makefile.PL + + It adds the contents of the PERL5LIB + environment variable to #! .../bin/perl line of + Perl scripts as -Idir + flags. This ensures that a script can find its + dependencies. + + In the fixup phase, it writes the propagated build + inputs (propagatedBuildInputs) to the file + $out/nix-support/propagated-user-env-packages. + nix-env recursively installs all packages listed + in this file when you install a package that has it. This ensures + that a Perl package can find its dependencies. + + + + + +buildPerlPackage is built on top of +stdenv, so everything can be customised in the +usual way. For instance, the BerkeleyDB module has +a preConfigure hook to generate a configuration +file used by Makefile.PL: + + +{buildPerlPackage, fetchurl, db4}: + +buildPerlPackage rec { + name = "BerkeleyDB-0.36"; + + src = fetchurl { + url = "mirror://cpan/authors/id/P/PM/PMQS/${name}.tar.gz"; + sha256 = "07xf50riarb60l1h6m2dqmql8q5dij619712fsgw7ach04d8g3z1"; + }; + + preConfigure = '' + echo "LIB = ${db4}/lib" > config.in + echo "INCLUDE = ${db4}/include" >> config.in + ''; +} + + + + +Dependencies on other Perl packages can be specified in the +buildInputs and +propagatedBuildInputs attributes. If something is +exclusively a build-time dependency, use +buildInputs; if it’s (also) a runtime dependency, +use propagatedBuildInputs. For instance, this +builds a Perl module that has runtime dependencies on a bunch of other +modules: + + +perlClassC3Componentised = buildPerlPackage rec { + name = "Class-C3-Componentised-1.0004"; + src = fetchurl { + url = "mirror://cpan/authors/id/A/AS/ASH/${name}.tar.gz"; + sha256 = "0xql73jkcdbq4q9m0b0rnca6nrlvf5hyzy8is0crdk65bynvs8q1"; + }; + propagatedBuildInputs = [ + perlClassC3 perlClassInspector perlTestException perlMROCompat + ]; +}; + + + + +
+ + +
Python + +TODO + +
+ + +
Haskell + +TODO + +
+ + +
Java + +TODO; Java support needs lots of improvement + +
+ + +
TeX / LaTeX + +* Special support for building TeX documents + +
+ + +
\ No newline at end of file diff --git a/doc/manual.xml b/doc/manual.xml index a16b783af31..9eb81ee2e59 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -32,41 +32,7 @@ - - - - - - Language Support - -
- Perl - * Generic Perl builder -
- -
- Python - * Wrapper generation -
- -
- Haskell - TODO -
- -
- Java - TODO; Java support needs lots of improvement -
- -
- TeX / LaTeX - * Special support for building TeX documents -
- -
- - +