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