Skip to content

Instantly share code, notes, and snippets.

@WolfangAukang
Last active August 9, 2023 17:03
Show Gist options
  • Save WolfangAukang/035d486aae0877f6322ebf2635f3e4d6 to your computer and use it in GitHub Desktop.
Save WolfangAukang/035d486aae0877f6322ebf2635f3e4d6 to your computer and use it in GitHub Desktop.
How to use Jupyter playbooks through Flakes (Nix)
{
description = "Jupyter playbook example";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) mkShell;
inherit (pkgs.python3Packages) ansible-kernel jupyter-c-kernel ilua jupyterlab numpy scipy matplotlib;
inherit (pkgs.lib) concatMapStringsSep;
kernels = [ ansible-kernel jupyter-c-kernel ilua ];
pyUtils = [ jupyterlab numpy scipy matplotlib ];
in {
devShells.default = mkShell {
buildInputs = pyUtils;
shellHook = ''
# kernels
export JUPYTER_PATH="${concatMapStringsSep ":" (p: "${p}/share/jupyter/") kernels}"
echo Lets do some python
alias start="jupyter lab"
'';
};
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment