2021-05-08 15:45:03 +02:00
|
|
|
{ stdenv, lib, R, libcxx, xvfb-run, util-linux, Cocoa, Foundation, gettext, gfortran }:
|
2014-05-04 23:54:11 +02:00
|
|
|
|
2018-08-02 18:06:36 +02:00
|
|
|
{ name, buildInputs ? [], requireX ? false, ... } @ attrs:
|
2014-05-04 23:54:11 +02:00
|
|
|
|
2015-02-19 21:49:41 +01:00
|
|
|
stdenv.mkDerivation ({
|
2018-03-14 23:58:20 +01:00
|
|
|
buildInputs = buildInputs ++ [R gettext] ++
|
2021-05-08 15:45:03 +02:00
|
|
|
lib.optionals requireX [util-linux xvfb-run] ++
|
2021-01-17 19:11:59 +01:00
|
|
|
lib.optionals stdenv.isDarwin [Cocoa Foundation gfortran];
|
2015-06-29 02:42:31 +02:00
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE =
|
llvmPackages: Multuple outputs for everythting
Also begin to start work on cross compilation, though that will have to
be finished later.
The patches are based on the first version of
https://reviews.llvm.org/D99484. It's very annoying to do the
back-porting but the review has uncovered nothing super major so I'm
fine sticking with what I've got.
Beyond making the outputs work, I also strove to re-sync the packages,
as they have been drifting pointlessly apart for some time.
----
Other misc notes, highly incomplete
- lvm-config-native and llvm-config are put in `dev` because they are
tools just for build time.
- Clang no longer has an lld dep. That was introduced in
db29857eb391ed002046090851a44c452b80bdbd, but if clang needs help
finding lld when it is used we should just pass it flags / put in the
resource dir. Providing it at build time increases critical path
length for no good reason.
----
A note on `nativeCC`:
`stdenv` takes tools from the previous stage, so:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.stdenv.cc`: `(?0, ?1, x)`
while:
1. `pkgsBuildBuild`: `(?1, x, x)`
2. `pkgsBuildBuild.targetPackages`: `(x, x, ?2)`
3. `pkgsBuildBuild.targetPackages.stdenv.cc`: `(?1, x, x)`
2020-10-15 10:23:57 +02:00
|
|
|
lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
|
2014-05-04 23:54:11 +02: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 07:29:56 +01:00
|
|
|
installFlags = if attrs.doCheck or true then
|
|
|
|
[]
|
2014-11-21 14:23:36 +01:00
|
|
|
else
|
2014-11-24 07:29:56 +01:00
|
|
|
[ "--no-test-load" ];
|
2014-11-21 14:23:36 +01:00
|
|
|
|
2018-08-02 18:06:36 +02:00
|
|
|
rCommand = if requireX then
|
2014-11-21 14:23:36 +01:00
|
|
|
# Unfortunately, xvfb-run has a race condition even with -a option, so that
|
|
|
|
# we acquire a lock explicitly.
|
2021-05-08 15:45:03 +02:00
|
|
|
"flock ${xvfb-run} xvfb-run -a -e xvfb-error R"
|
2014-11-21 14:23:36 +01:00
|
|
|
else
|
|
|
|
"R";
|
|
|
|
|
2014-05-04 23:54:11 +02:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/library
|
2014-11-24 07:29:56 +01:00
|
|
|
$rCommand CMD INSTALL $installFlags --configure-args="$configureFlags" -l $out/library .
|
2014-05-04 23:54:11 +02:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
2017-11-17 19:26:21 +01: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 23:54:11 +02:00
|
|
|
fi
|
|
|
|
'';
|
2014-11-24 07:29:56 +01:00
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
# noop since R CMD INSTALL tests packages
|
|
|
|
'';
|
2014-05-05 00:32:45 +02:00
|
|
|
} // attrs // {
|
|
|
|
name = "r-" + name;
|
|
|
|
})
|