[Services] Added modular service configuration + opt-in jupyterhub server

This commit is contained in:
Antoine Viallon 2022-02-22 23:04:10 +01:00
parent 771d557a83
commit cab07f3d14
Signed by: aviallon
GPG key ID: 186FC35EDEB25716
3 changed files with 70 additions and 0 deletions

6
services/default.nix Normal file
View file

@ -0,0 +1,6 @@
{ config, pkgs, ...}:
{
imports = [
./jupyterhub.nix
];
}

52
services/jupyterhub.nix Normal file
View file

@ -0,0 +1,52 @@
{config, pkgs, lib, ...}:
with lib;
let
cfg = config.aviallon.services.jupyterhub;
in
{
options.aviallon.services.jupyterhub = {
enable = mkEnableOption "Jupyterhub server with Python 3 kernel";
};
config = mkIf cfg.enable {
services.jupyterhub = {
enable = true;
kernels.python3 = let
env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
ipykernel
pandas
scikit-learn
pyspark
matplotlib
numpy
pip
]));
in {
displayName = "Python 3 for machine learning";
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";
};
};
services.nginx = {
enable = true;
};
services.nginx.virtualHosts = {
"jupyterhub.localhost" = {
listen = [ { addr = "0.0.0.0"; port = 80; } ];
locations."/" = {
proxyPass = "http://localhost:${toString config.services.jupyterhub.port}";
proxyWebsockets = true;
};
};
};
};
}