2023-04-29 16:46:19 +00:00
|
|
|
{ lib, stdenv, perl, toPerlModule }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
{ buildInputs ? []
|
|
|
|
, nativeBuildInputs ? []
|
|
|
|
, outputs ? [ "out" "devdoc" ]
|
|
|
|
, src ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
# enabling or disabling does nothing for perl packages so set it explicitly
|
|
|
|
# to false to not change hashes when enableParallelBuildingByDefault is enabled
|
|
|
|
, enableParallelBuilding ? false
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
, doCheck ? true
|
|
|
|
, checkTarget ? "test"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# Prevent CPAN downloads.
|
|
|
|
, PERL_AUTOINSTALL ? "--skipdeps"
|
2021-05-03 20:48:10 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# From http://wiki.cpantesters.org/wiki/CPANAuthorNotes: "allows
|
|
|
|
# authors to skip certain tests (or include certain tests) when
|
|
|
|
# the results are not being monitored by a human being."
|
|
|
|
, AUTOMATED_TESTING ? true
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# current directory (".") is removed from @INC in Perl 5.26 but many old libs rely on it
|
|
|
|
# https://metacpan.org/pod/release/XSAWYERX/perl-5.26.0/pod/perldelta.pod#Removal-of-the-current-directory-%28%22.%22%29-from-@INC
|
|
|
|
, PERL_USE_UNSAFE_INC ? "1"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
, env ? {}
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
, ...
|
|
|
|
}@attrs:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
lib.throwIf (attrs ? name) "buildPerlPackage: `name` (\"${attrs.name}\") is deprecated, use `pname` and `version` instead"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
(let
|
|
|
|
defaultMeta = {
|
2022-07-14 12:49:19 +00:00
|
|
|
homepage = "https://metacpan.org/dist/${attrs.pname}";
|
|
|
|
inherit (perl.meta) platforms;
|
2022-02-10 20:34:41 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
package = stdenv.mkDerivation (attrs // {
|
|
|
|
name = "perl${perl.version}-${attrs.pname}-${attrs.version}";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
builder = ./builder.sh;
|
2022-02-10 20:34:41 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = buildInputs ++ [ perl ];
|
2023-04-29 16:46:19 +00:00
|
|
|
nativeBuildInputs = nativeBuildInputs ++ (if stdenv.buildPlatform != stdenv.hostPlatform then [ perl.mini ] else [ perl ]);
|
2022-02-10 20:34:41 +00:00
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
inherit outputs src doCheck checkTarget enableParallelBuilding;
|
2023-01-20 10:41:00 +00:00
|
|
|
env = {
|
|
|
|
inherit PERL_AUTOINSTALL AUTOMATED_TESTING PERL_USE_UNSAFE_INC;
|
2023-04-29 16:46:19 +00:00
|
|
|
fullperl = perl.__spliced.buildHost or perl;
|
2023-01-20 10:41:00 +00:00
|
|
|
} // env;
|
2022-02-10 20:34:41 +00:00
|
|
|
|
|
|
|
meta = defaultMeta // (attrs.meta or { });
|
2022-07-14 12:49:19 +00:00
|
|
|
});
|
2022-02-10 20:34:41 +00:00
|
|
|
|
|
|
|
in toPerlModule package)
|