2024-06-07 16:13:55 +00:00
|
|
|
{ lib, perl, buildEnv, makeBinaryWrapper, stdenv
|
2019-04-09 14:49:47 +00:00
|
|
|
, extraLibs ? []
|
|
|
|
, extraOutputsToInstall ? []
|
|
|
|
, postBuild ? ""
|
|
|
|
, ignoreCollisions ? false
|
|
|
|
, requiredPerlModules
|
|
|
|
}:
|
|
|
|
|
|
|
|
# Create a perl executable that knows about additional packages.
|
|
|
|
let
|
|
|
|
env = let
|
|
|
|
paths = requiredPerlModules (extraLibs ++ [ perl ] );
|
|
|
|
in buildEnv {
|
|
|
|
name = "${perl.name}-env";
|
|
|
|
|
|
|
|
inherit paths;
|
|
|
|
inherit ignoreCollisions;
|
|
|
|
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
|
|
|
|
|
2024-06-07 16:13:55 +00:00
|
|
|
# TODO: remove stdenv.cc as soon as it is added to propagatedNativeBuildInputs of makeBinaryWrapper
|
|
|
|
nativeBuildInputs = [ makeBinaryWrapper stdenv.cc ];
|
2021-03-02 22:33:53 +00:00
|
|
|
|
2019-04-09 14:49:47 +00:00
|
|
|
# we create wrapper for the binaries in the different packages
|
|
|
|
postBuild = ''
|
|
|
|
if [ -L "$out/bin" ]; then
|
|
|
|
unlink "$out/bin"
|
|
|
|
fi
|
|
|
|
mkdir -p "$out/bin"
|
|
|
|
|
|
|
|
# take every binary from perl packages and put them into the env
|
2021-01-23 13:15:07 +00:00
|
|
|
for path in ${lib.concatStringsSep " " paths}; do
|
2019-04-09 14:49:47 +00:00
|
|
|
if [ -d "$path/bin" ]; then
|
|
|
|
cd "$path/bin"
|
|
|
|
for prg in *; do
|
|
|
|
if [ -f "$prg" ]; then
|
|
|
|
rm -f "$out/bin/$prg"
|
|
|
|
if [ -x "$prg" ]; then
|
2020-01-20 18:11:00 +00:00
|
|
|
makeWrapper "$path/bin/$prg" "$out/bin/$prg" --suffix PERL5LIB ':' "$out/${perl.libPrefix}"
|
2019-04-09 14:49:47 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
'' + postBuild;
|
|
|
|
|
|
|
|
meta = perl.meta // { outputsToInstall = ["out"]; }; # remove "man" from meta.outputsToInstall. pkgs.buildEnv produces no "man", it puts everything to "out"
|
|
|
|
|
|
|
|
passthru = perl.passthru // {
|
|
|
|
interpreter = "${env}/bin/perl";
|
|
|
|
inherit perl;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in env
|