From 118baa7be303a772215f200d08799cf9f2ac7166 Mon Sep 17 00:00:00 2001 From: prescientmoon Date: Tue, 21 May 2024 01:49:20 +0200 Subject: [PATCH] Add basic jupyter config --- docs/ports.md | 1 + hosts/nixos/lapetus/default.nix | 1 + hosts/nixos/lapetus/services/jupyter.nix | 46 ++++++++++++++++++++++++ scripts/dns/dns.txt | 1 + 4 files changed, 49 insertions(+) create mode 100644 hosts/nixos/lapetus/services/jupyter.nix diff --git a/docs/ports.md b/docs/ports.md index 193d432..a412faa 100644 --- a/docs/ports.md +++ b/docs/ports.md @@ -23,3 +23,4 @@ The idea is to always use consecutive ports, but never go back and try to recycl | 8417 | [qbittorrent](../hosts/nixos/lapetus/services/qbittorrent.nix) | | 8418 | [microbin](../hosts/nixos/lapetus/services/microbin.nix) | | 8419 | [forgejo](../hosts/nixos/lapetus/services/forgejo.nix) | +| 8420 | [jupyterjub](../hosts/nixos/lapetus/services/jupyter.nix) | diff --git a/hosts/nixos/lapetus/default.nix b/hosts/nixos/lapetus/default.nix index fe4a6c2..2e2dc96 100644 --- a/hosts/nixos/lapetus/default.nix +++ b/hosts/nixos/lapetus/default.nix @@ -24,6 +24,7 @@ ./services/qbittorrent.nix ./services/microbin.nix ./services/forgejo.nix + ./services/jupyter.nix # ./services/ddclient.nix ./filesystems ./hardware diff --git a/hosts/nixos/lapetus/services/jupyter.nix b/hosts/nixos/lapetus/services/jupyter.nix new file mode 100644 index 0000000..0513cbc --- /dev/null +++ b/hosts/nixos/lapetus/services/jupyter.nix @@ -0,0 +1,46 @@ +{ config, pkgs, ... }: { + services.nginx.virtualHosts."jupyter.moonythm.dev" = + config.satellite.proxy + config.services.jupyterhub.port + { proxyWebsockets = true; }; + + services.jupyterhub = { + enable = true; + port = 8420; + + extraConfig = '' + c.Authenticator.allowed_users = {'prescientmoon'} + c.Authenticator.admin_users = {'prescientmoon'} + + c.SystemdSpawner.mem_limit = '2G' + c.SystemdSpawner.cpu_limit = 2.0 + ''; + + # {{{ Python 3 kernel + kernels.python3 = + let env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [ + ipykernel + pandas + scikit-learn + ])); + 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"; + }; + # }}} + }; + + environment.persistence."/persist/state".directories = [ + "/var/lib/${config.services.jupyterhub.stateDirectory}" + ]; +} diff --git a/scripts/dns/dns.txt b/scripts/dns/dns.txt index c10e247..9276edf 100644 --- a/scripts/dns/dns.txt +++ b/scripts/dns/dns.txt @@ -19,6 +19,7 @@ git IN CNAME lapetus grafana IN CNAME lapetus intray IN CNAME lapetus irc IN CNAME lapetus +jupyter IN CNAME lapetus lab IN CNAME lapetus lapetus.syncthing IN CNAME lapetus ; TODO: might change this to syncthing.lapetus media IN CNAME lapetus