2024-08-26 17:38:47 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-05-22 14:04:20 +02:00
|
|
|
let
|
|
|
|
# {{{ Jupyterhub/lab env
|
2024-08-26 17:38:47 +02:00
|
|
|
appEnv = pkgs.python3.withPackages (
|
|
|
|
p: with p; [
|
|
|
|
jupyterhub
|
|
|
|
jupyterlab
|
|
|
|
jupyterhub-systemdspawner
|
|
|
|
jupyter-collaboration
|
|
|
|
jupyterlab-git
|
|
|
|
]
|
|
|
|
);
|
2024-05-21 02:12:55 +02:00
|
|
|
in
|
2024-08-26 17:38:47 +02:00
|
|
|
# }}}
|
2024-05-21 02:12:55 +02:00
|
|
|
{
|
2024-05-22 18:41:01 +02:00
|
|
|
systemd.services.jupyterhub.path = [
|
|
|
|
pkgs.texlive.combined.scheme-full # LaTeX stuff is useful for matplotlib
|
|
|
|
pkgs.git # Required by the git extension
|
|
|
|
];
|
2024-05-22 14:44:37 +02:00
|
|
|
|
2024-05-21 01:49:20 +02:00
|
|
|
services.jupyterhub = {
|
|
|
|
enable = true;
|
2024-07-08 03:06:27 +02:00
|
|
|
port = config.satellite.cloudflared.at.jupyter.port;
|
2024-05-21 01:49:20 +02:00
|
|
|
|
2024-05-21 02:12:55 +02:00
|
|
|
jupyterhubEnv = appEnv;
|
|
|
|
jupyterlabEnv = appEnv;
|
|
|
|
|
2024-05-21 02:54:34 +02:00
|
|
|
# {{{ Spwaner & auth config
|
2024-05-21 01:49:20 +02:00
|
|
|
extraConfig = ''
|
2024-08-26 17:38:47 +02:00
|
|
|
c.Authenticator.allowed_users = {'${config.users.users.pilot.name}', 'javi'}
|
|
|
|
c.Authenticator.admin_users = {'${config.users.users.pilot.name}'}
|
2024-05-21 01:49:20 +02:00
|
|
|
|
2024-05-21 02:25:58 +02:00
|
|
|
c.Spawner.notebook_dir='${config.users.users.pilot.home}/projects/notebooks'
|
2024-05-21 01:49:20 +02:00
|
|
|
c.SystemdSpawner.mem_limit = '2G'
|
|
|
|
c.SystemdSpawner.cpu_limit = 2.0
|
|
|
|
'';
|
2024-05-21 02:54:34 +02:00
|
|
|
# }}}
|
2024-05-21 01:49:20 +02:00
|
|
|
# {{{ Python 3 kernel
|
|
|
|
kernels.python3 =
|
2024-08-26 17:38:47 +02:00
|
|
|
let
|
|
|
|
env = (
|
|
|
|
pkgs.python3.withPackages (
|
|
|
|
p: with p; [
|
|
|
|
ipykernel
|
|
|
|
numpy
|
|
|
|
scipy
|
|
|
|
matplotlib
|
|
|
|
tabulate
|
|
|
|
]
|
|
|
|
)
|
|
|
|
);
|
2024-05-21 01:49:20 +02:00
|
|
|
in
|
|
|
|
{
|
2024-05-21 02:40:58 +02:00
|
|
|
displayName = "Numerical mathematics setup";
|
2024-05-21 01:49:20 +02:00
|
|
|
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-05-21 02:40:58 +02:00
|
|
|
# {{{ Javi user
|
|
|
|
sops.secrets.javi_password = {
|
|
|
|
sopsFile = ../secrets.yaml;
|
|
|
|
neededForUsers = true;
|
|
|
|
};
|
|
|
|
|
2024-05-21 02:42:49 +02:00
|
|
|
users.users.javi = {
|
|
|
|
isNormalUser = true;
|
|
|
|
hashedPasswordFile = config.sops.secrets.javi_password.path;
|
|
|
|
};
|
2024-05-21 02:40:58 +02:00
|
|
|
# }}}
|
2024-05-21 02:54:34 +02:00
|
|
|
# {{{ Networking & storage
|
2024-07-08 03:13:12 +02:00
|
|
|
satellite.cloudflared.at.jupyter.port = config.satellite.ports.jupyterhub;
|
2024-05-21 02:54:34 +02:00
|
|
|
|
2024-05-21 01:49:20 +02:00
|
|
|
environment.persistence."/persist/state".directories = [
|
|
|
|
"/var/lib/${config.services.jupyterhub.stateDirectory}"
|
|
|
|
];
|
2024-05-21 02:40:58 +02:00
|
|
|
# }}}
|
2024-05-21 01:49:20 +02:00
|
|
|
}
|