Skip to content

Commit

Permalink
shell.nix: Pin R to prevent API breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Baker committed Dec 4, 2023
1 parent c254dd4 commit 757e8e7
Showing 1 changed file with 65 additions and 37 deletions.
102 changes: 65 additions & 37 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,43 +1,71 @@
{ pkgs ? import ./nixpkgs.nix { }, ghc ? pkgs.haskell.compiler.ghc8107 }:

with pkgs;

{
pkgs ? import ./nixpkgs.nix {},
ghc ? pkgs.haskell.compiler.ghc8107,
}:
let
# Uncomment the line below to build HaskellR against a version of R with
callPackage = pkgs.lib.flip pkgs.callPackage {inherit R;};
# Set enableStrictBarrier to true to build HaskellR against a version of R with
# the --enable-strict-barrier configure flag enabled for better memory
# diagnostics.
R = (pkgs.R.override {enableStrictBarrier = false;}).overrideAttrs (
# Pin R to a specific version to avoid breaking changes in the R API.
finalAttrs: prevAttrs: {
version = "4.2.3";
src = pkgs.fetchurl {
url = "https://cran.r-project.org/src/base/R-${pkgs.lib.versions.major finalAttrs.version}/R-${finalAttrs.version}.tar.gz";
sha256 = "sha256-VeSpptQ74xTiwD0CZqb6VESv3OULMDv8O4Kzl5UW4HQ=";
};
}
);
in
callPackage (
{
fetchurl,
haskell,
lib,
python3,
rPackages,
rWrapper,
stdenv,
zeromq,
R,
zlib,
}:
let
# NOTE: Workaround https://ghc.haskell.org/trac/ghc/ticket/11042.
libHack =
if stdenv.isDarwin then
{DYLD_LIBRARY_PATH = ["${R}/lib/R/lib"];}
else
{LD_LIBRARY_PATH = ["${R}/lib/R"];};

# R = pkgs.R.override { enableStrictBarrier = true; };

# XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042.
libHack =
if stdenv.isDarwin
then { DYLD_LIBRARY_PATH = [ "${R}/lib/R/lib" ]; }
else { LD_LIBRARY_PATH = [ "${R}/lib/R" ]; }
;

python3Env = python3.withPackages (ps: with ps; [
ipython
jupyter_client
notebook
]);
python3Env = python3.withPackages (
ps:
with ps; [
ipython
jupyter_client
notebook
]
);

rEnv = rWrapper.override {
packages = with rPackages; [
rEnv = rWrapper.override {
inherit R;
# ggplot2 is required for ./IHaskell/examples/tutorial-ihaskell-inline-r.ipynb
ggplot2
];
};
in

haskell.lib.buildStackProject ({
name = "HaskellR";
inherit ghc;
buildInputs = [
zeromq
zlib
python3Env
rEnv
];
LANG = "en_US.UTF-8";
} // libHack)
packages = with rPackages; [ggplot2];
};
in
haskell.lib.buildStackProject (
{
name = "HaskellR";
inherit ghc;
buildInputs = [
zeromq
zlib
python3Env
rEnv
];
LANG = "en_US.UTF-8";
}
// libHack
)
)

0 comments on commit 757e8e7

Please sign in to comment.