summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--pkgs/applications/science/math/R/default.nix30
-rw-r--r--pkgs/development/r-modules/default.nix5
-rw-r--r--pkgs/development/r-modules/generic-builder.nix8
-rw-r--r--pkgs/top-level/all-packages.nix2
4 files changed, 34 insertions, 11 deletions
diff --git a/pkgs/applications/science/math/R/default.nix b/pkgs/applications/science/math/R/default.nix
index 183a1f50375..edbf8a843a5 100644
--- a/pkgs/applications/science/math/R/default.nix
+++ b/pkgs/applications/science/math/R/default.nix
@@ -1,7 +1,7 @@
-{ stdenv, fetchurl, bzip2, gfortran, libX11, libXmu, libXt
-, libjpeg, libpng, libtiff, ncurses, pango, pcre, perl, readline, tcl
-, texLive, tk, xz, zlib, less, texinfo, graphviz, icu, pkgconfig, bison
-, imake, which, jdk, openblas, curl
+{ stdenv, fetchurl, bzip2, gfortran, libX11, libXmu, libXt, libjpeg, libpng
+, libtiff, ncurses, pango, pcre, perl, readline, tcl, texLive, tk, xz, zlib
+, less, texinfo, graphviz, icu, pkgconfig, bison, imake, which, jdk, openblas
+, curl, Cocoa, Foundation, cf-private, libobjc, tzdata
 , withRecommendedPackages ? true
 }:
 
@@ -14,10 +14,11 @@ stdenv.mkDerivation rec {
   };
 
   buildInputs = [ bzip2 gfortran libX11 libXmu libXt
-    libXt libjpeg libpng libtiff ncurses pango pcre perl readline tcl
-    texLive tk xz zlib less texinfo graphviz icu pkgconfig bison imake
-    which jdk openblas curl
-  ];
+    libXt libjpeg libpng libtiff ncurses pango pcre perl readline
+    texLive xz zlib less texinfo graphviz icu pkgconfig bison imake
+    which jdk openblas curl ]
+    ++ stdenv.lib.optionals (!stdenv.isDarwin) [ tcl tk ]
+    ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa Foundation cf-private libobjc ];
 
   patches = [ ./no-usr-local-search-paths.patch ];
 
@@ -48,10 +49,23 @@ stdenv.mkDerivation rec {
       LDFLAGS="-L${gfortran.cc}/lib"
       RANLIB=$(type -p ranlib)
       R_SHELL="${stdenv.shell}"
+  '' + stdenv.lib.optionalString stdenv.isDarwin ''
+      --without-tcltk
+      --without-aqua
+      --disable-R-framework
+      CC="clang"
+      CXX="clang++"
+      OBJC="clang"
+  '' + ''
     )
     echo "TCLLIBPATH=${tk}/lib" >>etc/Renviron.in
   '';
 
+  postConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
+    sed -i 's|/usr/share/zoneinfo|${tzdata}/share/zoneinfo|g' src/library/base/R/datetime.R
+    sed -i 's|getenv("R_SHARE_DIR")|"${tzdata}/share"|g' src/extra/tzone/localtime.c
+  '';
+
   installTargets = [ "install" "install-info" "install-pdf" ];
 
   doCheck = true;
diff --git a/pkgs/development/r-modules/default.nix b/pkgs/development/r-modules/default.nix
index d72f9bca03d..68e9fc6b458 100644
--- a/pkgs/development/r-modules/default.nix
+++ b/pkgs/development/r-modules/default.nix
@@ -5,7 +5,10 @@
 let
   inherit (pkgs) fetchurl stdenv lib;
 
-  buildRPackage = pkgs.callPackage ./generic-builder.nix { inherit R; };
+  buildRPackage = pkgs.callPackage ./generic-builder.nix {
+    inherit R;
+    inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa Foundation;
+  };
 
   # Generates package templates given per-repository settings
   #
diff --git a/pkgs/development/r-modules/generic-builder.nix b/pkgs/development/r-modules/generic-builder.nix
index 45c377635c9..62883af2c73 100644
--- a/pkgs/development/r-modules/generic-builder.nix
+++ b/pkgs/development/r-modules/generic-builder.nix
@@ -1,10 +1,14 @@
-{ stdenv, R, xvfb_run, utillinux }:
+{ stdenv, R, libcxx, xvfb_run, utillinux, Cocoa, Foundation }:
 
 { name, buildInputs ? [], ... } @ attrs:
 
 stdenv.mkDerivation ({
   buildInputs = buildInputs ++ [R] ++
-                stdenv.lib.optionals attrs.requireX [utillinux xvfb_run];
+                stdenv.lib.optionals attrs.requireX [utillinux xvfb_run] ++
+                stdenv.lib.optionals stdenv.isDarwin [Cocoa Foundation];
+
+  NIX_CFLAGS_COMPILE =
+    stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
 
   configurePhase = ''
     runHook preConfigure
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index acbb0f68e43..ddf1e999b86 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -9078,6 +9078,8 @@ let
     };
     openblas = openblasCompat;
     withRecommendedPackages = false;
+    inherit (darwin.apple_sdk.frameworks) Cocoa Foundation;
+    inherit (darwin) cf-private libobjc;
   };
 
   rWrapper = callPackage ../development/r-modules/wrapper.nix {