about summary refs log tree commit diff
path: root/nix/hosts/corrino/www/jupyter.emile.space.nix
blob: d1d951ce06d58dba350d58b803129a14bcbb36f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ pkgs, lib, config, ... }:

{
  services.nginx.virtualHosts."jupyter.emile.space" = {
    forceSSL = true;
    enableACME = true;

    locations = {
      "/" = {
        proxyPass = "http://127.0.0.1:8004";
      };
    };
  };

  services.jupyter = rec {
    enable = true;

    ip = "127.0.0.1";
    port = 8004;

    # ; python3
    # >>> from notebook.auth import passwd
    # >>> passwd("the_password_here")
    password = "'argon2:$argon2id$v=19$m=10240,t=10,p=8$WdU+DaBjTaiV1IQDRJUczg$N734yZ45++Kgl26lFEZau58ru8e7P/IgL9N6sf+kw9E'";

    notebookConfig = ''
      c.NotebookApp.allow_remote_access = True
      c.NotebookApp.allow_origin = '*'
    '';

    kernels = {
      python3 = let
        env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
                ipykernel
              ]));
      in {
        displayName = "Python 3";
        argv = [
          "${env.interpreter}"
          "-m"
          "ipykernel_launcher"
          "-f"
          "{connection_file}"
        ];
        language = "python";
        #logo32 = "${env.sitePackages}/ipykernel/resources/logo-32x32.png";
        #logo64 = "${env.sitePackages}/ipykernel/resources/logo-64x64.png";
        extraPaths = {
          "cool.txt" = pkgs.writeText "cool" "cool content";
        };
      };
    };

    group = "jupyter";
    user = "jupyter";
  };

  users.users.jupyter.group = "jupyter";
  users.groups.jupyter = {};
}