diff options
author | Malo Bourgon <mbourgon@gmail.com> | 2022-06-07 11:03:48 -0700 |
---|---|---|
committer | Malo Bourgon <mbourgon@gmail.com> | 2022-06-07 12:49:23 -0700 |
commit | 399732b449262e8e3183fd239274b284901c8d08 (patch) | |
tree | 4114e9d85f4c2eff33ad9b02ef48f9ec7c0e88f1 /doc/languages-frameworks/perl.section.md | |
parent | 61beb33b83c16339fdcd96680d2942040730679e (diff) |
buildPerlPackage: don't mess with `pname` and phase out use of `name`
Currently `buildPerlPackage` prefixes the Perl version to the package's `pname`, which results in `nix run` not being able to work for any packages build with it out of the box. This commit corrects that and phases out the ability to set `name` directly, as well as refactors the code to not require `cleanedAttrs`.
Diffstat (limited to 'doc/languages-frameworks/perl.section.md')
-rw-r--r-- | doc/languages-frameworks/perl.section.md | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/doc/languages-frameworks/perl.section.md b/doc/languages-frameworks/perl.section.md index 9bfd209fec5a4..28a78cc234410 100644 --- a/doc/languages-frameworks/perl.section.md +++ b/doc/languages-frameworks/perl.section.md @@ -1,6 +1,6 @@ # Perl {#sec-language-perl} -## Running perl programs on the shell {#ssec-perl-running} +## Running Perl programs on the shell {#ssec-perl-running} When executing a Perl script, it is possible you get an error such as `./myscript.pl: bad interpreter: /usr/bin/perl: no such file or directory`. This happens when the script expects Perl to be installed at `/usr/bin/perl`, which is not the case when using Perl from nixpkgs. You can fix the script by changing the first line to: @@ -35,15 +35,16 @@ Perl packages from CPAN are defined in [pkgs/top-level/perl-packages.nix](https: ```nix ClassC3 = buildPerlPackage rec { - name = "Class-C3-0.21"; + pname = "Class-C3"; + version = "0.21"; src = fetchurl { - url = "mirror://cpan/authors/id/F/FL/FLORA/${name}.tar.gz"; + url = "mirror://cpan/authors/id/F/FL/FLORA/${pname}-${version}.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. Perl packages are made available in `all-packages.nix` through the variable `perlPackages`. For instance, if you have a package that needs `ClassC3`, you would typically write +Note the use of `mirror://cpan/`, and the `pname` and `version` in the URL definition to ensure that the `pname` attribute is consistent with the source that we’re actually downloading. Perl packages are made available in `all-packages.nix` through the variable `perlPackages`. For instance, if you have a package that needs `ClassC3`, you would typically write ```nix foo = import ../path/to/foo.nix { @@ -72,10 +73,11 @@ So what does `buildPerlPackage` do? It does the following: { buildPerlPackage, fetchurl, db }: buildPerlPackage rec { - name = "BerkeleyDB-0.36"; + pname = "BerkeleyDB"; + version = "0.36"; src = fetchurl { - url = "mirror://cpan/authors/id/P/PM/PMQS/${name}.tar.gz"; + url = "mirror://cpan/authors/id/P/PM/PMQS/${pname}-${version}.tar.gz"; sha256 = "07xf50riarb60l1h6m2dqmql8q5dij619712fsgw7ach04d8g3z1"; }; @@ -90,9 +92,10 @@ Dependencies on other Perl packages can be specified in the `buildInputs` and `p ```nix ClassC3Componentised = buildPerlPackage rec { - name = "Class-C3-Componentised-1.0004"; + pname = "Class-C3-Componentised"; + version = "1.0004"; src = fetchurl { - url = "mirror://cpan/authors/id/A/AS/ASH/${name}.tar.gz"; + url = "mirror://cpan/authors/id/A/AS/ASH/${pname}-${version}.tar.gz"; sha256 = "0xql73jkcdbq4q9m0b0rnca6nrlvf5hyzy8is0crdk65bynvs8q1"; }; propagatedBuildInputs = [ @@ -111,7 +114,7 @@ ImageExifTool = buildPerlPackage { version = "11.50"; src = fetchurl { - url = "https://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-11.50.tar.gz"; + url = "https://www.sno.phy.queensu.ca/~phil/exiftool/${pname}-${version}.tar.gz"; sha256 = "0d8v48y94z8maxkmw1rv7v9m0jg2dc8xbp581njb6yhr7abwqdv3"; }; @@ -139,9 +142,10 @@ This program takes a Perl module name, looks it up on CPAN, fetches and unpacks ```ShellSession $ nix-generate-from-cpan XML::Simple XMLSimple = buildPerlPackage rec { - name = "XML-Simple-2.22"; + pname = "XML-Simple"; + version = "2.22"; src = fetchurl { - url = "mirror://cpan/authors/id/G/GR/GRANTM/${name}.tar.gz"; + url = "mirror://cpan/authors/id/G/GR/GRANTM/XML-Simple-2.22.tar.gz"; sha256 = "b9450ef22ea9644ae5d6ada086dc4300fa105be050a2030ebd4efd28c198eb49"; }; propagatedBuildInputs = [ XMLNamespaceSupport XMLSAX XMLSAXExpat ]; |