2024-01-16 11:01:22 -05:00
|
|
|
{ config, pkgs, lib, ... }: {
|
|
|
|
services.jupyterhub = {
|
|
|
|
enable = true;
|
|
|
|
port = 6501;
|
|
|
|
# https://github.com/jupyterhub/systemdspawner
|
|
|
|
# Configuration options defined ^
|
|
|
|
extraConfig = ''
|
|
|
|
c.SystemdSpawner.mem_limit = '2G'
|
|
|
|
c.SystemdSpawner.cpu_limit = 1.0
|
2024-02-01 20:02:53 -05:00
|
|
|
c.SystemdSpawner.isolate_devices = False
|
|
|
|
c.SystemdSpawner.extra_paths = [
|
|
|
|
'${pkgs.buildEnv {
|
|
|
|
name = "jupyterhub-system-spawner-env";
|
|
|
|
paths = with pkgs; [
|
|
|
|
gcc
|
|
|
|
];
|
|
|
|
}}/bin']
|
2024-01-16 11:01:22 -05:00
|
|
|
'';
|
2024-01-17 17:20:04 -05:00
|
|
|
# Extra Paths used to add gcc et al for packages like Brian2
|
|
|
|
# https://github.com/jupyterhub/systemdspawner#extra_paths
|
2024-01-16 15:00:48 -05:00
|
|
|
|
2024-01-23 14:05:22 -05:00
|
|
|
jupyterlabEnv = pkgs.python3.withPackages (p: with p; [
|
|
|
|
jupyterhub
|
|
|
|
jupyterlab
|
|
|
|
# Extensions:
|
|
|
|
jupyter-collaboration
|
|
|
|
jupyter-server-mathjax
|
|
|
|
jupyter-console
|
|
|
|
jupyterlab-lsp
|
|
|
|
python-lsp-server
|
|
|
|
]);
|
|
|
|
|
2024-01-16 11:01:22 -05:00
|
|
|
kernels = {
|
2024-01-16 11:17:40 -05:00
|
|
|
python3 = let
|
|
|
|
env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
|
|
|
|
# Necessary for use as a kernel
|
|
|
|
ipykernel
|
2024-01-16 15:00:48 -05:00
|
|
|
ipdb
|
|
|
|
# Interactive widgets
|
|
|
|
ipywidgets
|
|
|
|
# Show images/media
|
|
|
|
mediapy
|
|
|
|
# Progress bars etc. for in Jupyter/IPython
|
|
|
|
halo
|
2024-01-16 11:01:22 -05:00
|
|
|
|
2024-01-16 11:17:40 -05:00
|
|
|
# Common Python Libraries
|
|
|
|
numpy
|
|
|
|
scipy
|
|
|
|
scikit-learn
|
|
|
|
pandas
|
2024-01-16 15:00:48 -05:00
|
|
|
# Tables displayed in Jupyter: like Pandas Dataframes
|
|
|
|
ipytablewidgets
|
2024-01-16 11:17:40 -05:00
|
|
|
matplotlib
|
2024-01-16 15:00:48 -05:00
|
|
|
ipympl
|
|
|
|
matplotlib-inline
|
2024-01-16 11:17:40 -05:00
|
|
|
seaborn
|
2024-01-16 11:01:22 -05:00
|
|
|
|
2024-01-16 11:17:40 -05:00
|
|
|
# Neural Data Processing Libraries
|
2024-01-16 13:57:25 -05:00
|
|
|
# Temporarily broken?: https://github.com/NixOS/nixpkgs/issues/259812
|
|
|
|
# mne-python
|
2024-01-16 11:17:40 -05:00
|
|
|
nibabel
|
2024-01-16 15:00:48 -05:00
|
|
|
# View niftis!
|
|
|
|
ipyniivue
|
2024-01-16 11:17:40 -05:00
|
|
|
neo
|
|
|
|
|
|
|
|
# Neurosimulators
|
|
|
|
neuronpy
|
2024-01-16 15:00:48 -05:00
|
|
|
# nest with MPI is incompatible with Jupyter:
|
|
|
|
# https://www.nest-simulator.org/pynest-api/_modules/nest.html
|
|
|
|
# see pynestkernel comments about their workaround
|
|
|
|
(nest.override {
|
|
|
|
withMpi = false;
|
|
|
|
})
|
2024-01-16 11:17:40 -05:00
|
|
|
brian2
|
2024-02-01 20:02:53 -05:00
|
|
|
|
|
|
|
# Machine learning toolkits:
|
|
|
|
tensorflow
|
|
|
|
tensorboard
|
|
|
|
keras
|
|
|
|
edward
|
|
|
|
transformers
|
|
|
|
tflearn
|
|
|
|
torch
|
|
|
|
torchvision
|
|
|
|
torchsde
|
|
|
|
torchmetrics
|
|
|
|
torchio
|
|
|
|
torchdiffeq
|
|
|
|
botorch
|
|
|
|
lion-pytorch
|
|
|
|
])).override (args: { ignoreCollisions = true; });
|
|
|
|
# Odd collision between tensorboard of torch & tensorflow
|
|
|
|
# need to resolve later
|
2024-01-16 11:17:40 -05:00
|
|
|
in {
|
|
|
|
displayName = "Python 3 for Computational Neuroscience";
|
|
|
|
argv = [
|
|
|
|
"${env.interpreter}"
|
|
|
|
"-m"
|
|
|
|
"ipykernel_launcher"
|
|
|
|
"-f"
|
|
|
|
"{connection_file}"
|
|
|
|
];
|
|
|
|
language = "python";
|
|
|
|
logo32 = "${env}/${env.sitePackages}/ipykernel/resources/logo-32x32.png";
|
|
|
|
logo64 = "${env}/${env.sitePackages}/ipykernel/resources/logo-64x64.png";
|
2024-01-16 11:01:22 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-01-17 17:20:04 -05:00
|
|
|
|
2024-01-16 11:01:22 -05:00
|
|
|
services.caddy.virtualHosts = {
|
|
|
|
"jupyter.ws.kcnhub.com" = {
|
|
|
|
extraConfig = ''
|
|
|
|
reverse_proxy 127.0.0.1:${toString config.services.jupyterhub.port}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|