perl: add .withPackages

This commit is contained in:
volth
2019-04-09 14:49:47 +00:00
parent 68f7f25706
commit 03eaa480bd
5 changed files with 103 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
{ lib, stdenv, fetchurl, buildPackages
{ config, lib, stdenv, fetchurl, buildPackages, callPackage
, enableThreading ? stdenv ? glibc, makeWrapper
}:
@@ -22,7 +22,8 @@ let
libcInc = lib.getDev libc;
libcLib = lib.getLib libc;
crossCompiling = stdenv.buildPlatform != stdenv.hostPlatform;
common = { version, sha256 }: stdenv.mkDerivation (rec {
common = { self, version, sha256 }: stdenv.mkDerivation (rec {
inherit version;
name = "perl-${version}";
@@ -104,7 +105,19 @@ let
setupHook = ./setup-hook.sh;
passthru.libPrefix = "lib/perl5/site_perl";
passthru = rec {
interpreter = "${self}/bin/perl";
libPrefix = "lib/perl5/site_perl";
pkgs = callPackage ../../../top-level/perl-packages.nix {
perl = self;
overrides = config.perlPackageOverrides or (p: {}); # TODO: (self: super: {}) like in python
};
buildEnv = callPackage ./wrapper.nix {
perl = self;
inherit (pkgs) requiredPerlModules;
};
withPackages = f: buildEnv.override { extraLibs = f pkgs; };
};
doCheck = false; # some tests fail, expensive
@@ -179,12 +192,14 @@ let
in rec {
# the latest Maint version
perl528 = common {
self = perl528;
version = "5.28.1";
sha256 = "0iy3as4hnbjfyws4in3j9d6zhhjxgl5m95i5n9jy2bnzcpz8bgry";
};
# the latest Devel version
perldevel = common {
self = perldevel;
version = "5.29.9";
sha256 = "017x3nghyc5m8q1yqnrdma96b3d5rlfx87vv5mi64jq0r8k6zppm";
};

View File

@@ -0,0 +1,55 @@
{ stdenv, perl, buildEnv, makeWrapper
, extraLibs ? []
, extraOutputsToInstall ? []
, postBuild ? ""
, ignoreCollisions ? false
, lib
, requiredPerlModules
, makeWrapperArgs ? []
}:
# 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" --set 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