The existence of WSL 2, the nix
package manager, and tweag.io's jupyterWith
project make it (relatively) easy to set up a working
jupyter notebook with the iHaskell
kernel in windows 10.
- If you don't already have it up and running, start by making you sure you have WSL 2 installed and activated, by following the instructions here. At the time of writing, you need to join the windows insiders program (slow ring is sufficient).
- I use Ubuntu from the windows store with WSL 2, but the following instructions should be compatible with any distribution.
- Open a ubuntu terminal and install the nix package manager by running the following command:
curl https://nixos.org/nix/install | sh
- Now install the nix binary cache manager
cachix
using nix, with the following command. This is strictly speaking optional, but highly recommended as it will significantly speed up subsequent steps.
nix-env -iA cachix -f https://cachix.org/api/v1/install
- Enable the
jupyterWith
cache by running the following command:
cachix use jupyterwith
- Create and cd into a new directory. Let's call it
ihaskell-test
. - Create an empty directory within
ihaskell-test
calledjupyterlab
. - Create a new file in
ihaskell-test
calledshell.nix
, with the following contents:
let
jupyter = import (builtins.fetchGit {
url = https://github.com/tweag/jupyterWith;
rev = "";
}) { config = {allowBroken = true;};};
iHaskell = jupyter.kernels.iHaskellWith {
name = "haskell";
packages = p: with p; [ hvega formatting ];
};
jupyterEnvironment =
jupyter.jupyterlabWith {
kernels = [ iHaskell ];
directory = ./jupyterlab;
};
in
jupyterEnvironment.env
- Inside of
ihaskell-test
runnix-shell
. It will take a while for everything to build. - Once the process has finished, run
generate-directory jupyterlab-ihaskell
This is necessary for syntax highlighting to work. - Now, exit the nix shell environment via
Ctrl-D
. - Finally, run the following command to start the notebook:
nix-shell --command "jupyter lab"
- You can navigate to the provided url in a windows browser to access the notebook interface.
Happy hacking!