depot/third_party/nixpkgs/pkgs/development/interpreters/perl/wrapper.nix
Default email 8ac5e011d6 Project import generated by Copybara.
GitOrigin-RevId: 2c3273caa153ee8eb5786bc8141b85b859e7efd7
2020-04-24 19:36:52 -04:00

53 lines
1.5 KiB
Nix

{ stdenv, perl, buildEnv, makeWrapper
, 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;
# we create wrapper for the binaries in the different packages
postBuild = ''
. "${makeWrapper}/nix-support/setup-hook"
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
for path in ${stdenv.lib.concatStringsSep " " paths}; do
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
makeWrapper "$path/bin/$prg" "$out/bin/$prg" --suffix PERL5LIB ':' "$out/${perl.libPrefix}"
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