nixpkgs/pkgs/development/r-modules/generic-builder.nix
Andrew Childs 7869d16545 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
  db29857eb3, 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)`
2021-04-30 05:41:00 +00:00

55 lines
1.4 KiB
Nix

{ stdenv, lib, R, libcxx, xvfb_run, util-linux, Cocoa, Foundation, gettext, gfortran }:
{ name, buildInputs ? [], requireX ? false, ... } @ attrs:
stdenv.mkDerivation ({
buildInputs = buildInputs ++ [R gettext] ++
lib.optionals requireX [util-linux xvfb_run] ++
lib.optionals stdenv.isDarwin [Cocoa Foundation gfortran];
NIX_CFLAGS_COMPILE =
lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
configurePhase = ''
runHook preConfigure
export R_LIBS_SITE="$R_LIBS_SITE''${R_LIBS_SITE:+:}$out/library"
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
runHook postBuild
'';
installFlags = if attrs.doCheck or true then
[]
else
[ "--no-test-load" ];
rCommand = if requireX 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";
installPhase = ''
runHook preInstall
mkdir -p $out/library
$rCommand CMD INSTALL $installFlags --configure-args="$configureFlags" -l $out/library .
runHook postInstall
'';
postFixup = ''
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
fi
'';
checkPhase = ''
# noop since R CMD INSTALL tests packages
'';
} // attrs // {
name = "r-" + name;
})