Last active
August 24, 2021 18:35
-
-
Save fusetim/e59b17fc9bac31f2e43174fccd14d7e9 to your computer and use it in GitHub Desktop.
ocaml-jupyter kernel for Nix and JupyterWith
This file contains 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
{ name ? "nixpkgs", packages ? [] }: | |
let | |
pkgs = import <nixpkgs> {}; | |
kernelSpecFile = pkgs.writeText "kernel.json" (builtins.toJSON { | |
argv = [ | |
"{out-path}/bin/ocaml-jupyter-kernel" | |
"-init" | |
"/home/$USER/.ocamlinit" | |
"--merlin" | |
"{merlin-path}/bin/ocamlmerlin" | |
"--verbosity" | |
"app" | |
"--connection-file" | |
"{connection_file}" | |
]; | |
display_name = "Ocaml - ${name}"; | |
language = "Ocaml"; | |
}); | |
OcamlKernel = pkgs.ocamlPackages.buildDunePackage rec { | |
pname = "jupyter"; | |
version = "2.7.5"; | |
useDune2 = true; | |
minimalOCamlVersion = "4.04"; | |
src = pkgs.fetchFromGitHub { | |
owner = "akabe"; | |
repo = "ocaml-jupyter"; | |
rev = "v${version}"; | |
sha256 = "0dayyhvw3ynvncy9b7daiz3bcybfh38mbivgr693i16ld3gp6c6v"; | |
}; | |
#checkInputs = [ alcotest ppx_let ]; | |
buildInputs = [ | |
pkgs.ocamlPackages.ocaml-syntax-shims | |
pkgs.ocamlPackages.yojson | |
pkgs.ocamlPackages.lwt_ppx | |
pkgs.ocamlPackages.ppx_deriving | |
pkgs.ocamlPackages.ppx_deriving_yojson | |
pkgs.ocamlPackages.base64 | |
pkgs.ocamlPackages.uuidm | |
pkgs.ocamlPackages.logs | |
pkgs.ocamlPackages.cryptokit | |
pkgs.ocamlPackages.zmq | |
pkgs.ocamlPackages.zmq-lwt | |
pkgs.ocamlPackages.cppo | |
pkgs.ocamlPackages.ounit | |
pkgs.ocamlPackages.merlin | |
]; | |
propagatedBuildInputs = [ pkgs.ocamlPackages.bigstringaf pkgs.ocamlPackages.result ]; | |
# Tests does not pass | |
# doCheck = pkgs.lib.versionAtLeast pkgs.ocaml.version "4.05"; | |
postInstall = '' | |
export kerneldir=$out/kernels/ocaml_${pkgs.ocaml.version} | |
mkdir -p $kerneldir | |
substitute ${kernelSpecFile} $kerneldir/kernel.json \ | |
--replace "{merlin-path}" ${pkgs.ocamlPackages.merlin} \ | |
--replace "{out-path}" $out | |
''; | |
#jupyter kernelspec install --name ocaml-jupyter-${version} "$out/lib/ocaml/${pkgs.ocaml.version}/site-lib/jupyter" | |
#''; | |
meta = with pkgs.lib; { | |
homepage = "https://github.com/akabe/ocaml-jupyter"; | |
description = "An OCaml kernel for Jupyter (IPython) notebook."; | |
license = pkgs.lib.licenses.mit; | |
maintainers = with lib.maintainers; [ akabe ]; | |
}; | |
}; | |
in | |
{ | |
spec = OcamlKernel; | |
runtimePackages = packages pkgs ++ OcamlKernel.buildInputs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment