Created
June 26, 2020 12:28
-
-
Save idontgetoutmuch/bb4838c47284c99623f7fa0b1efeca8c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
pkgs = { | |
ihaskell = builtins.fetchTarball { | |
url = "https://github.com/gibiansky/IHaskell/tarball/cc427517a59bfc8e1014c7e02fe5cfe0ce7e5eef"; | |
sha256 = "0lpy70zagc1h3i1ihq83fm3af9ypfkwsi0b21hjiz5lkrplp9cna"; | |
}; | |
nixpkgs = builtins.fetchTarball { | |
url = "https://github.com/NixOS/nixpkgs/archive/19.09.tar.gz"; | |
sha256 = "0mhqhq21y5vrr1f30qd2bvydv4bbbslvyzclhw0kdxmkgg3z4c92"; | |
}; | |
}; | |
rOverlay = rself: rsuper: { | |
myR = rsuper.rWrapper.override { | |
packages = with rsuper.rPackages; [ ggplot2 dplyr xts purrr cmaes cubature ]; | |
}; | |
}; | |
foo = self: super: { | |
haskell = super.haskell // { packageOverrides = | |
hself: hsuper: { | |
my-random-fu-multivariate = hself.callPackage ./pkgs/random-fu-multivariate { }; | |
}; | |
}; | |
}; | |
nixpkgs = import pkgs.nixpkgs { overlays = [ rOverlay foo ]; }; | |
r-libs-site = nixpkgs.runCommand "r-libs-site" { | |
buildInputs = with nixpkgs; [ R rPackages.ggplot2 rPackages.dplyr rPackages.xts rPackages.purrr rPackages.cmaes rPackages.cubature ]; | |
} ''echo $R_LIBS_SITE > $out''; | |
ihaskellEnv = (import "${pkgs.ihaskell}/release.nix" { | |
compiler = "ghc864"; | |
nixpkgs = nixpkgs; | |
packages = self: [ | |
self.inline-r | |
self.cassava | |
# we can re-introduce this when it gets fixed | |
# self.hmatrix-sundials | |
self.random-fu | |
self.random-source | |
self.my-random-fu-multivariate | |
]; | |
}).passthru.ihaskellEnv; | |
systemPackages = self: [ self.myR ]; | |
jupyterlab = nixpkgs.python3.withPackages (ps: [ ps.jupyterlab ]); | |
rtsopts = "-M3g -N2"; | |
ihaskellJupyterCmdSh = cmd: extraArgs: nixpkgs.writeScriptBin "ihaskell-${cmd}" '' | |
#! ${nixpkgs.stdenv.shell} | |
export GHC_PACKAGE_PATH="$(echo ${ihaskellEnv}/lib/*/package.conf.d| tr ' ' ':'):$GHC_PACKAGE_PATH" | |
export R_LIBS_SITE=${builtins.readFile r-libs-site} | |
export PATH="${nixpkgs.stdenv.lib.makeBinPath ([ ihaskellEnv jupyterlab ] ++ systemPackages nixpkgs)}''${PATH:+:}$PATH" | |
${ihaskellEnv}/bin/ihaskell install \ | |
-l $(${ihaskellEnv}/bin/ghc --print-libdir) \ | |
--use-rtsopts="${rtsopts}" \ | |
&& ${jupyterlab}/bin/jupyter ${cmd} ${extraArgs} "$@" | |
''; | |
in | |
nixpkgs.buildEnv { | |
name = "ihaskell-with-packages"; | |
buildInputs = [ nixpkgs.makeWrapper ]; | |
paths = [ ihaskellEnv jupyterlab ]; | |
postBuild = '' | |
echo "Hello" | |
ln -s ${ihaskellJupyterCmdSh "lab" ""}/bin/ihaskell-lab $out/bin/ | |
ln -s ${ihaskellJupyterCmdSh "notebook" ""}/bin/ihaskell-notebook $out/bin/ | |
ln -s ${ihaskellJupyterCmdSh "nbconvert" ""}/bin/ihaskell-nbconvert $out/bin/ | |
ln -s ${ihaskellJupyterCmdSh "console" "--kernel=haskell"}/bin/ihaskell-console $out/bin/ | |
echo $out/bin | |
for prg in $out/bin"/"*;do | |
if [[ -f $prg && -x $prg ]]; then | |
wrapProgram $prg --set PYTHONPATH "$(echo ${jupyterlab}/lib/*/site-packages)" | |
fi | |
done | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment