Instantly share code, notes, and snippets.

Embed
What would you like to do?
An OCaml environment for use with `nix-shell`
with import <nixpkgs> {};
let
ocamlPackages = pkgs.recurseIntoAttrs pkgs.ocamlPackages_latest;
ocamlVersion = (builtins.parseDrvName ocamlPackages.ocaml.name).version;
merlinWithEmacsMode = ocamlPackages.merlin.override { withEmacsMode = true; };
findlibSiteLib = "${ocamlPackages.findlib}/lib/ocaml/${ocamlVersion}/site-lib";
ocamlInit = pkgs.writeText "ocamlinit" ''
let () =
try Topdirs.dir_directory "${findlibSiteLib}"
with Not_found -> ()
;;
#use "topfind";;
#thread;;
#camlp4o;;
#require "core";;
#require "core.syntax";;
'';
in
stdenv.mkDerivation rec {
name = "rwo-shell";
src = null;
buildInputs = with ocamlPackages;
[ ocaml
camlp4
core
core_extended
findlib
merlinWithEmacsMode
pa_ounit
pa_test
utop
];
# For my Emacs config...
MERLIN_SITE_LISP = "${merlinWithEmacsMode}/share/emacs/site-lisp";
UTOP_SITE_LISP = "${ocamlPackages.utop}/share/emacs/site-lisp";
OCAMLINIT = "${ocamlInit}";
shellHook = ''
alias utop="utop -init ${ocamlInit}"
alias ocaml="ocaml -init ${ocamlInit}"
'';
}
@henrytill

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment