2024-02-07 17:20:01 -05:00
|
|
|
{ config, pkgs, lib, ... }: let
|
|
|
|
aiomcache = pkgs.python3.pkgs.buildPythonPackage rec {
|
|
|
|
pname = "aio-memcache";
|
|
|
|
version = "0.8.1";
|
|
|
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "aio-libs";
|
|
|
|
repo = "aiomcache";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-oRMN1seEjFSsq4wjkIXHM7Osq8y/5WFExGCEr6eM9vc=";
|
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = with pkgs.python3.pkgs; [
|
|
|
|
python-memcached
|
|
|
|
];
|
|
|
|
|
|
|
|
# Networking required
|
|
|
|
doCheck = false;
|
|
|
|
};
|
|
|
|
aiohttp-session = pkgs.python3.pkgs.buildPythonPackage rec {
|
|
|
|
pname = "aiohttp-session";
|
|
|
|
version = "2.12.0";
|
|
|
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "aio-libs";
|
|
|
|
repo = "aiohttp-session";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-7MNah4OIQnoxLoZkLOdeu5uCwSyPMhc6Wsht8dFconc=";
|
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = with pkgs.python3.pkgs; [
|
|
|
|
aiohttp
|
|
|
|
aiomcache
|
|
|
|
cryptography
|
|
|
|
multidict
|
|
|
|
pynacl
|
|
|
|
redis
|
|
|
|
yarl
|
|
|
|
];
|
|
|
|
|
|
|
|
# Checks require networking
|
|
|
|
doCheck = false;
|
|
|
|
};
|
|
|
|
matlab-proxy = pkgs.python3.pkgs.buildPythonPackage rec {
|
|
|
|
pname = "matlab_proxy";
|
|
|
|
version = "0.12.1";
|
|
|
|
format = "wheel";
|
|
|
|
src = pkgs.python3.pkgs.fetchPypi {
|
|
|
|
inherit pname version format;
|
|
|
|
dist = "py3";
|
|
|
|
python = "py3";
|
|
|
|
hash = "sha256-TDZUJEXJYF5Vh2BG5o13H3wdh/WdVdoESXqL89ckc6I=";
|
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = with pkgs.python3.pkgs; [
|
|
|
|
aiohttp
|
|
|
|
aiohttp-session
|
|
|
|
psutil
|
|
|
|
|
|
|
|
# For Xvfb, for plots and graphics
|
|
|
|
pkgs.xorg.xorgserver
|
|
|
|
];
|
|
|
|
};
|
|
|
|
simpervisor = pkgs.python3.pkgs.buildPythonPackage rec {
|
|
|
|
pname = "simpervisor";
|
|
|
|
version = "1.0.0";
|
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
|
|
owner = "jupyterhub";
|
|
|
|
repo = "simpervisor";
|
|
|
|
rev = "v${version}";
|
|
|
|
hash = "sha256-73vkiQtOT0M9Vww1nYZ76JR2koWt/NPIav46k1fHOzc=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs.python3.pkgs; [
|
|
|
|
hatchling
|
|
|
|
];
|
|
|
|
};
|
|
|
|
jupyter-server-proxy = pkgs.python3.pkgs.buildPythonPackage rec {
|
|
|
|
pname = "jupyter_server_proxy";
|
|
|
|
version = "4.1.0";
|
|
|
|
format = "pyproject";
|
|
|
|
|
|
|
|
src = pkgs.python3.pkgs.fetchPypi {
|
|
|
|
inherit pname version;
|
|
|
|
hash = "sha256-LPrDtCMv5xROjmApa0+GFwi08TspJgos8ol2v45hf3A=";
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs.python3.pkgs; [
|
|
|
|
hatchling
|
|
|
|
hatch-jupyter-builder
|
|
|
|
hatch-nodejs-version
|
|
|
|
jupyterlab
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = with pkgs.python3.pkgs; [
|
|
|
|
notebook
|
|
|
|
simpervisor
|
|
|
|
aiohttp
|
|
|
|
];
|
|
|
|
|
|
|
|
# tests require network
|
|
|
|
doCheck = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
jupyter-matlab-proxy = pkgs.python3.pkgs.buildPythonPackage rec {
|
|
|
|
pname = "jupyter_matlab_proxy";
|
|
|
|
version = "0.11.0";
|
|
|
|
format = "wheel";
|
|
|
|
|
|
|
|
src = pkgs.python3.pkgs.fetchPypi {
|
|
|
|
inherit pname version format;
|
|
|
|
python = "py3";
|
|
|
|
dist = "py3";
|
|
|
|
hash = "sha256-KzQgs1zXGPjONCnLvCNQkQBkkkn9J29YFi8BHbh+D1I=";
|
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = with pkgs.python3.pkgs; [
|
|
|
|
jupyter-server-proxy
|
|
|
|
simpervisor
|
|
|
|
matlab-proxy
|
|
|
|
psutil
|
|
|
|
requests
|
|
|
|
ipykernel
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in {
|
2024-01-16 11:01:22 -05:00
|
|
|
services.jupyterhub = {
|
|
|
|
enable = true;
|
|
|
|
port = 6501;
|
|
|
|
# https://github.com/jupyterhub/systemdspawner
|
|
|
|
# Configuration options defined ^
|
2024-02-07 17:20:01 -05:00
|
|
|
# mem_limit must be higher to allow for MATLAB
|
2024-01-16 11:01:22 -05:00
|
|
|
extraConfig = ''
|
2024-07-10 10:29:40 -04:00
|
|
|
c.SystemdSpawner.mem_limit = '32G'
|
2024-02-07 17:20:01 -05:00
|
|
|
c.SystemdSpawner.cpu_limit = 2.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
|
2024-02-07 17:20:01 -05:00
|
|
|
# For MATLAB Kernel
|
|
|
|
matlab
|
|
|
|
# For matlab-proxy-app
|
|
|
|
(pkgs.python3.withPackages (p: with p; [
|
|
|
|
# For pkg_resources
|
|
|
|
setuptools
|
|
|
|
matlab-proxy
|
|
|
|
jupyter-matlab-proxy
|
|
|
|
]))
|
2024-02-01 20:02:53 -05:00
|
|
|
];
|
|
|
|
}}/bin']
|
2024-02-07 17:20:01 -05:00
|
|
|
c.SystemdSpawner.environment["MATLAB_INSTALL_DIR"] = "${config.environment.sessionVariables.MATLAB_INSTALL_DIR}"
|
|
|
|
c.SystemdSpawner.environment["LM_LICENSE_FILE"] = "${config.environment.sessionVariables.LM_LICENSE_FILE}"
|
|
|
|
c.SystemdSpawner.environment["MLM_LICENSE_FILE"] = "${config.environment.sessionVariables.MLM_LICENSE_FILE}"
|
|
|
|
# c.SystemdSpawner.environment["MWI_JUPYTER_LOG_LEVEL"] = "DEBUG"
|
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:
|
2024-07-10 10:29:40 -04:00
|
|
|
# jupyter-collaboration
|
2024-01-23 14:05:22 -05:00
|
|
|
jupyter-server-mathjax
|
|
|
|
jupyter-console
|
|
|
|
jupyterlab-lsp
|
|
|
|
python-lsp-server
|
2024-02-07 17:20:01 -05:00
|
|
|
# MATLAB Proxy Needs to be here in order to modify and add the "launch matlab" etc.
|
|
|
|
jupyter-matlab-proxy # <-- This in effect adds the kernel
|
2024-01-23 14:05:22 -05:00
|
|
|
]);
|
|
|
|
|
2024-01-16 11:01:22 -05:00
|
|
|
kernels = {
|
2024-01-16 11:17:40 -05:00
|
|
|
python3 = let
|
2024-05-10 14:38:47 -04:00
|
|
|
env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages;
|
|
|
|
(config.pythonPackages pythonPackages) ++ [
|
2024-01-16 11:17:40 -05:00
|
|
|
# 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
|
|
|
|
# Tables displayed in Jupyter: like Pandas Dataframes
|
|
|
|
ipytablewidgets
|
2024-02-01 20:02:53 -05:00
|
|
|
])).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}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|