diff --git a/flake.nix b/flake.nix index 14ddb50..d2c8f06 100644 --- a/flake.nix +++ b/flake.nix @@ -79,6 +79,7 @@ pkgs = import nixpkgs { system = "x86_64-linux"; }; in { next-web = import ./shells/next-web.nix { inherit pkgs; }; + jupyter = import ./shells/jupyter.nix { inherit pkgs; }; }; }; }; diff --git a/shells/jupyter.nix b/shells/jupyter.nix new file mode 100644 index 0000000..5d0b939 --- /dev/null +++ b/shells/jupyter.nix @@ -0,0 +1,40 @@ +{ pkgs }: +let + py = pkgs.python312; + pyEnv = py.withPackages (ps: with ps; [ + ipykernel + notebook + jupyterlab + numpy + pandas + matplotlib + scipy + scikit-learn + ]); +in +pkgs.mkShell { + name = "jupyter-notebook"; + + packages = with pkgs; [ + pyEnv + zsh + ]; + + PYTHONNOUSERSITE = "1"; + JUPYTER_CONFIG_DIR = "$PWD/.jupyter"; + IPYTHONDIR = "$PWD/.ipython"; + + shellHook = '' + set -e + + # ---- show tool versions + if command -v python >/dev/null; then + echo "📓 jupyter shell → python $(python -V | awk '{print $2}')" + fi + + if [ -z "''${ZSH_VERSION:-}" ] && [[ $- == *i* ]] && [ -t 1 ] && [ -z "''${NIX_SHELL_ZSH_ACTIVATED:-}" ]; then + export NIX_SHELL_ZSH_ACTIVATED=1 + exec ${pkgs.zsh}/bin/zsh -i + fi + ''; +}