From c8108bdebbab46072a70384b91ba11f6cf926c02 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Wed, 28 Aug 2024 14:00:07 -0400 Subject: [PATCH] Infini-DL360/jupyter: init --- hosts/Infini-DL360/default.nix | 1 + hosts/Infini-DL360/jupyter.nix | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 hosts/Infini-DL360/jupyter.nix diff --git a/hosts/Infini-DL360/default.nix b/hosts/Infini-DL360/default.nix index 2942475..227655c 100644 --- a/hosts/Infini-DL360/default.nix +++ b/hosts/Infini-DL360/default.nix @@ -12,6 +12,7 @@ ./freshrss.nix ./hydra.nix ./jellyfin.nix + ./jupyter.nix ./postgresql.nix ./thelounge.nix ./vaultwarden.nix diff --git a/hosts/Infini-DL360/jupyter.nix b/hosts/Infini-DL360/jupyter.nix new file mode 100644 index 0000000..7cbc6ef --- /dev/null +++ b/hosts/Infini-DL360/jupyter.nix @@ -0,0 +1,63 @@ +{ config, pkgs, ... }: +let + mkPythonKernel = displayName: env: { + inherit displayName; + language = "python"; + argv = [ "${env.interpreter}" "-m" "ipykernel_launcher" "-f" "{connection_file}" ]; + logo32 = "${env}/${env.sitePackages}/ipykernel/resources/logo-32x32.png"; + logo64 = "${env}/${env.sitePackages}/ipykernel/resources/logo-64x64.png"; + }; +in +{ + services.jupyter = { + enable = true; + package = pkgs.python3Packages.jupyterlab; + + # Hosted behind Tailscale, so security doesn't matter + command = "jupyter-lab --ServerApp.token='' --ServerApp.password=''"; + password = "''"; + ip = "*"; + + user = "infinidoge"; + group = "users"; + notebookDir = "~/Notebooks"; + + kernels = { + python3 = mkPythonKernel "Python 3" (pkgs.python3.withPackages (p: with p; [ + ipykernel + nbconvert + nbformat + + matplotlib + numpy + pandas + scipy + ])); + }; + }; + + systemd.services.jupyter.path = with pkgs; [ + pandoc + (texlive.combine { + inherit (texlive) + scheme-medium + + adjustbox + enumitem + environ + pdfcol + tcolorbox + titling + upquote + ; + }) + ]; + + services.nginx.virtualHosts."jupyter.internal.inx.moe" = config.common.nginx.ssl // { + listenAddresses = [ "100.101.102.124" ]; + locations."/" = { + proxyPass = "http://localhost:${toString config.services.jupyter.port}"; + proxyWebsockets = true; + }; + }; +}