2020-11-24 15:29:28 +00:00
|
|
|
{ stdenv, R, libcxx, xvfb_run, util-linux, Cocoa, Foundation, gettext, gfortran }:
|
2014-05-04 22:54:11 +01:00
|
|
|
|
2018-08-02 17:06:36 +01:00
|
|
|
{ name, buildInputs ? [], requireX ? false, ... } @ attrs:
|
2014-05-04 22:54:11 +01:00
|
|
|
|
2015-02-19 20:49:41 +00:00
|
|
|
stdenv.mkDerivation ({
|
2018-03-14 22:58:20 +00:00
|
|
|
buildInputs = buildInputs ++ [R gettext] ++
|
2020-11-24 15:29:28 +00:00
|
|
|
stdenv.lib.optionals requireX [util-linux xvfb_run] ++
|
2018-03-14 22:58:20 +00:00
|
|
|
stdenv.lib.optionals stdenv.isDarwin [Cocoa Foundation gfortran];
|
2015-06-29 01:42:31 +01:00
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE =
|
|
|
|
stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
|
2014-05-04 22:54:11 +01: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 06:29:56 +00:00
|
|
|
installFlags = if attrs.doCheck or true then
|
|
|
|
[]
|
2014-11-21 13:23:36 +00:00
|
|
|
else
|
2014-11-24 06:29:56 +00:00
|
|
|
[ "--no-test-load" ];
|
2014-11-21 13:23:36 +00:00
|
|
|
|
2018-08-02 17:06:36 +01:00
|
|
|
rCommand = if requireX then
|
2014-11-21 13:23:36 +00:00
|
|
|
# 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-04 22:54:11 +01:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/library
|
2014-11-24 06:29:56 +00:00
|
|
|
$rCommand CMD INSTALL $installFlags --configure-args="$configureFlags" -l $out/library .
|
2014-05-04 22:54:11 +01:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
2017-11-17 18:26:21 +00:00
|
|
|
if test -e $out/nix-support/propagated-build-inputs; then
|
|
|
|
ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
|
2014-05-04 22:54:11 +01:00
|
|
|
fi
|
|
|
|
'';
|
2014-11-24 06:29:56 +00:00
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
# noop since R CMD INSTALL tests packages
|
|
|
|
'';
|
2014-05-04 23:32:45 +01:00
|
|
|
} // attrs // {
|
|
|
|
name = "r-" + name;
|
|
|
|
})
|