2016-04-20 00:46:35 +03:00
|
|
|
{ stdenv, R, libcxx, xvfb_run, utillinux, Cocoa, Foundation, gettext, gfortran }:
|
2014-05-05 01:54:11 +04:00
|
|
|
|
|
|
|
{ name, buildInputs ? [], ... } @ attrs:
|
|
|
|
|
2015-02-19 23:49:41 +03:00
|
|
|
stdenv.mkDerivation ({
|
|
|
|
buildInputs = buildInputs ++ [R] ++
|
2015-06-29 03:42:31 +03:00
|
|
|
stdenv.lib.optionals attrs.requireX [utillinux xvfb_run] ++
|
2016-04-20 00:46:35 +03:00
|
|
|
stdenv.lib.optionals stdenv.isDarwin [Cocoa Foundation gettext gfortran];
|
2015-06-29 03:42:31 +03:00
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE =
|
|
|
|
stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
|
2014-05-05 01:54:11 +04:00
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
export R_LIBS_SITE="$R_LIBS_SITE''${R_LIBS_SITE:+:}$out/library"
|
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
2014-11-24 09:29:56 +03:00
|
|
|
installFlags = if attrs.doCheck or true then
|
|
|
|
[]
|
2014-11-21 16:23:36 +03:00
|
|
|
else
|
2014-11-24 09:29:56 +03:00
|
|
|
[ "--no-test-load" ];
|
2014-11-21 16:23:36 +03:00
|
|
|
|
|
|
|
rCommand = if attrs.requireX or false then
|
|
|
|
# Unfortunately, xvfb-run has a race condition even with -a option, so that
|
|
|
|
# we acquire a lock explicitly.
|
|
|
|
"flock ${xvfb_run} xvfb-run -a -e xvfb-error R"
|
|
|
|
else
|
|
|
|
"R";
|
|
|
|
|
2014-05-05 01:54:11 +04:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/library
|
2014-11-24 09:29:56 +03:00
|
|
|
$rCommand CMD INSTALL $installFlags --configure-args="$configureFlags" -l $out/library .
|
2014-05-05 01:54:11 +04:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
if test -e $out/nix-support/propagated-native-build-inputs; then
|
|
|
|
ln -s $out/nix-support/propagated-native-build-inputs $out/nix-support/propagated-user-env-packages
|
|
|
|
fi
|
|
|
|
'';
|
2014-11-24 09:29:56 +03:00
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
# noop since R CMD INSTALL tests packages
|
|
|
|
'';
|
2014-05-05 02:32:45 +04:00
|
|
|
} // attrs // {
|
|
|
|
name = "r-" + name;
|
|
|
|
})
|