Skip to content

Instantly share code, notes, and snippets.

@idontgetoutmuch
Created August 30, 2019 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idontgetoutmuch/516f1f437e8ebabd771b06028cce29a5 to your computer and use it in GitHub Desktop.
Save idontgetoutmuch/516f1f437e8ebabd771b06028cce29a5 to your computer and use it in GitHub Desktop.
Haskell Package Set?
let
pkgs = {
ihaskell = builtins.fetchTarball {
url = "https://github.com/gibiansky/IHaskell/tarball/bb2500c448c35ca79bddaac30b799d42947e8774";
sha256 = "1n4yqxaf2xcnjfq0r1v7mzjhrizx7z5b2n6gj1kdk2yi37z672py";
};
nixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs-channels/tarball/49dc8087a20e0d742d38be5f13333a03d171006a";
sha256 = "1fdnqm4vyj50jb2ydcc0nldxwn6wm7qakxfhmpf72pz2y2ld55i6";
};
};
rOverlay = rself: rsuper: {
myR = rsuper.rWrapper.override {
packages = with rsuper.rPackages; [ ggplot2 dplyr xts purrr cmaes cubature ];
};
};
foo = self: super: {
haskell = super.haskell.override { 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.hmatrix
# we can re-introduce this when it gets fixed
# self.hmatrix-sundials
self.random-fu
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 = ''
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/
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