lol

Merge pull request #176792 from malob/fix-buildPerlPackages-pname

authored by

Sandro and committed by
GitHub
fe72f925 c605c54a

+21 -28
+15 -11
doc/languages-frameworks/perl.section.md
··· 1 # Perl {#sec-language-perl} 2 3 - ## Running perl programs on the shell {#ssec-perl-running} 4 5 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: 6 ··· 35 36 ```nix 37 ClassC3 = buildPerlPackage rec { 38 - name = "Class-C3-0.21"; 39 src = fetchurl { 40 - url = "mirror://cpan/authors/id/F/FL/FLORA/${name}.tar.gz"; 41 sha256 = "1bl8z095y4js66pwxnm7s853pi9czala4sqc743fdlnk27kq94gz"; 42 }; 43 }; 44 ``` 45 46 - 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 47 48 ```nix 49 foo = import ../path/to/foo.nix { ··· 72 { buildPerlPackage, fetchurl, db }: 73 74 buildPerlPackage rec { 75 - name = "BerkeleyDB-0.36"; 76 77 src = fetchurl { 78 - url = "mirror://cpan/authors/id/P/PM/PMQS/${name}.tar.gz"; 79 sha256 = "07xf50riarb60l1h6m2dqmql8q5dij619712fsgw7ach04d8g3z1"; 80 }; 81 ··· 90 91 ```nix 92 ClassC3Componentised = buildPerlPackage rec { 93 - name = "Class-C3-Componentised-1.0004"; 94 src = fetchurl { 95 - url = "mirror://cpan/authors/id/A/AS/ASH/${name}.tar.gz"; 96 sha256 = "0xql73jkcdbq4q9m0b0rnca6nrlvf5hyzy8is0crdk65bynvs8q1"; 97 }; 98 propagatedBuildInputs = [ ··· 111 version = "11.50"; 112 113 src = fetchurl { 114 - url = "https://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-11.50.tar.gz"; 115 sha256 = "0d8v48y94z8maxkmw1rv7v9m0jg2dc8xbp581njb6yhr7abwqdv3"; 116 }; 117 ··· 139 ```ShellSession 140 $ nix-generate-from-cpan XML::Simple 141 XMLSimple = buildPerlPackage rec { 142 - name = "XML-Simple-2.22"; 143 src = fetchurl { 144 - url = "mirror://cpan/authors/id/G/GR/GRANTM/${name}.tar.gz"; 145 sha256 = "b9450ef22ea9644ae5d6ada086dc4300fa105be050a2030ebd4efd28c198eb49"; 146 }; 147 propagatedBuildInputs = [ XMLNamespaceSupport XMLSAX XMLSAXExpat ];
··· 1 # Perl {#sec-language-perl} 2 3 + ## Running Perl programs on the shell {#ssec-perl-running} 4 5 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: 6 ··· 35 36 ```nix 37 ClassC3 = buildPerlPackage rec { 38 + pname = "Class-C3"; 39 + version = "0.21"; 40 src = fetchurl { 41 + url = "mirror://cpan/authors/id/F/FL/FLORA/${pname}-${version}.tar.gz"; 42 sha256 = "1bl8z095y4js66pwxnm7s853pi9czala4sqc743fdlnk27kq94gz"; 43 }; 44 }; 45 ``` 46 47 + 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 48 49 ```nix 50 foo = import ../path/to/foo.nix { ··· 73 { buildPerlPackage, fetchurl, db }: 74 75 buildPerlPackage rec { 76 + pname = "BerkeleyDB"; 77 + version = "0.36"; 78 79 src = fetchurl { 80 + url = "mirror://cpan/authors/id/P/PM/PMQS/${pname}-${version}.tar.gz"; 81 sha256 = "07xf50riarb60l1h6m2dqmql8q5dij619712fsgw7ach04d8g3z1"; 82 }; 83 ··· 92 93 ```nix 94 ClassC3Componentised = buildPerlPackage rec { 95 + pname = "Class-C3-Componentised"; 96 + version = "1.0004"; 97 src = fetchurl { 98 + url = "mirror://cpan/authors/id/A/AS/ASH/${pname}-${version}.tar.gz"; 99 sha256 = "0xql73jkcdbq4q9m0b0rnca6nrlvf5hyzy8is0crdk65bynvs8q1"; 100 }; 101 propagatedBuildInputs = [ ··· 114 version = "11.50"; 115 116 src = fetchurl { 117 + url = "https://www.sno.phy.queensu.ca/~phil/exiftool/${pname}-${version}.tar.gz"; 118 sha256 = "0d8v48y94z8maxkmw1rv7v9m0jg2dc8xbp581njb6yhr7abwqdv3"; 119 }; 120 ··· 142 ```ShellSession 143 $ nix-generate-from-cpan XML::Simple 144 XMLSimple = buildPerlPackage rec { 145 + pname = "XML-Simple"; 146 + version = "2.22"; 147 src = fetchurl { 148 + url = "mirror://cpan/authors/id/G/GR/GRANTM/XML-Simple-2.22.tar.gz"; 149 sha256 = "b9450ef22ea9644ae5d6ada086dc4300fa105be050a2030ebd4efd28c198eb49"; 150 }; 151 propagatedBuildInputs = [ XMLNamespaceSupport XMLSAX XMLSAXExpat ];
+6 -17
pkgs/development/perl-modules/generic/default.nix
··· 27 , ... 28 }@attrs: 29 30 - assert attrs?pname -> attrs?version; 31 - assert attrs?pname -> !(attrs?name); 32 - 33 - lib.warnIf (attrs ? name) "builtPerlPackage: `name' (\"${attrs.name}\") is deprecated, use `pname' and `version' instead" 34 35 (let 36 defaultMeta = { 37 - homepage = "https://metacpan.org/release/${lib.getName attrs}"; # TODO: phase-out `attrs.name` 38 - mainProgram = attrs.pname or (builtins.parseDrvName attrs.name).name; 39 - platforms = perl.meta.platforms; 40 }; 41 42 - cleanedAttrs = builtins.removeAttrs attrs [ 43 - "meta" "builder" "version" "pname" "fullperl" 44 - "buildInputs" "nativeBuildInputs" "buildInputs" 45 - "PERL_AUTOINSTALL" "AUTOMATED_TESTING" "PERL_USE_UNSAFE_INC" 46 - ]; 47 - 48 - package = stdenv.mkDerivation ({ 49 - pname = "perl${perl.version}-${lib.getName attrs}"; # TODO: phase-out `attrs.name` 50 - version = lib.getVersion attrs; # TODO: phase-out `attrs.name` 51 52 builder = ./builder.sh; 53 ··· 60 inherit PERL_AUTOINSTALL AUTOMATED_TESTING PERL_USE_UNSAFE_INC; 61 62 meta = defaultMeta // (attrs.meta or { }); 63 - } // cleanedAttrs); 64 65 in toPerlModule package)
··· 27 , ... 28 }@attrs: 29 30 + lib.throwIf (attrs ? name) "buildPerlPackage: `name` (\"${attrs.name}\") is deprecated, use `pname` and `version` instead" 31 32 (let 33 defaultMeta = { 34 + homepage = "https://metacpan.org/dist/${attrs.pname}"; 35 + inherit (perl.meta) platforms; 36 }; 37 38 + package = stdenv.mkDerivation (attrs // { 39 + name = "perl${perl.version}-${attrs.pname}-${attrs.version}"; 40 41 builder = ./builder.sh; 42 ··· 49 inherit PERL_AUTOINSTALL AUTOMATED_TESTING PERL_USE_UNSAFE_INC; 50 51 meta = defaultMeta // (attrs.meta or { }); 52 + }); 53 54 in toPerlModule package)