initial commit
This commit is contained in:
commit
7a61703608
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# Go Path
|
||||
.bin
|
||||
|
||||
# Jupyter Data
|
||||
.data
|
||||
|
||||
# Virtual Environment
|
||||
.venv
|
||||
|
||||
# Jupyter Checkpoints
|
||||
.ipynb_checkpoints
|
||||
|
||||
# Direnv Data
|
||||
.direnv
|
||||
|
||||
# Notebook Path
|
||||
notebooks/
|
2
Makefile
Normal file
2
Makefile
Normal file
@ -0,0 +1,2 @@
|
||||
run_jupyter:
|
||||
jupyter notebook --ip 127.0.0.1 --port 8888 --no-browser --allow-root --notebook-dir=./notebooks
|
9
README.md
Normal file
9
README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Nix Jupyter Notebooks
|
||||
|
||||
The following is a quick way to utilize Nix (`shell.nix`) and `direnv` to automatically spin up a Jupyter environment with both a Python3 and GoNB Kernel.
|
||||
|
||||
## Running
|
||||
|
||||
```
|
||||
make run_jupyter
|
||||
```
|
72
shell.nix
Normal file
72
shell.nix
Normal file
@ -0,0 +1,72 @@
|
||||
with import <nixpkgs> { };
|
||||
|
||||
pkgs.mkShell rec {
|
||||
venvDir = "./.venv";
|
||||
buildInputs = [
|
||||
|
||||
# Install Python & Packages
|
||||
(python3.withPackages (ps: with python3Packages; [
|
||||
jupyter
|
||||
ipython
|
||||
ipykernel
|
||||
|
||||
setuptools
|
||||
virtualenv
|
||||
pip
|
||||
pyqt5
|
||||
|
||||
pandas
|
||||
numpy
|
||||
matplotlib
|
||||
scipy
|
||||
]))
|
||||
|
||||
# Install Go (GoNB)
|
||||
go
|
||||
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
# Export Environment Paths
|
||||
export GOBIN=$(pwd)/.bin
|
||||
export PATH=$PATH:$(pwd)/.bin
|
||||
export JUPYTER_DATA_DIR=$(pwd)/.data
|
||||
|
||||
# Upsert Notebook Directory
|
||||
mkdir -p ./notebooks
|
||||
|
||||
# Install GoNB
|
||||
go install github.com/janpfeifer/gonb@latest
|
||||
go install golang.org/x/tools/cmd/goimports@latest
|
||||
go install golang.org/x/tools/gopls@latest
|
||||
|
||||
# # fixes libstdc++ issues and libgl.so issues
|
||||
# LD_LIBRARY_PATH=${stdenv.cc.cc.lib}/lib/:/run/opengl-driver/lib/
|
||||
#
|
||||
# # Fix XCB Issues
|
||||
# QT_PLUGIN_PATH=${qt5.qtbase}/${qt5.qtbase.qtPluginPrefix}
|
||||
# SOURCE_DATE_EPOCH=$(date +%s)
|
||||
# QT_XCB_GL_INTEGRATION="none"
|
||||
|
||||
# Upsert Virtual Environment
|
||||
if [ -d "${venvDir}" ]; then
|
||||
echo "Skipping venv creation, '${venvDir}' already exists"
|
||||
else
|
||||
echo "Creating new venv environment in path: '${venvDir}'"
|
||||
${python3.interpreter} -m venv "${venvDir}"
|
||||
fi
|
||||
|
||||
# Update Python Path
|
||||
PYTHONPATH=$PWD/${venvDir}/${python3.sitePackages}/:$PYTHONPATH
|
||||
|
||||
# Activate Virtual Environment
|
||||
source "${venvDir}/bin/activate"
|
||||
|
||||
# Update PIP
|
||||
python -m pip install --upgrade pip
|
||||
python -m ipykernel install --user --name=${venvDir}
|
||||
|
||||
# Install GoNB
|
||||
gonb --install
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user