Add JupyterHub
TODO: Add documentation about customizing and making requests for JupyterHubmaster
							parent
							
								
									14e2dca865
								
							
						
					
					
						commit
						b887e7036d
					
				| 
						 | 
				
			
			@ -8,5 +8,7 @@
 | 
			
		|||
    ./servers/guac.nix
 | 
			
		||||
    # Overleaf (Collaborative LaTeX)
 | 
			
		||||
    ./servers/overleaf.nix
 | 
			
		||||
    # Basic remote editting in jupyer notebooks
 | 
			
		||||
    ./servers/jupyterhub.nix
 | 
			
		||||
  ];
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,61 @@
 | 
			
		|||
{ config, pkgs, lib, ... }: {
 | 
			
		||||
  services.jupyterhub = {
 | 
			
		||||
    enable = true;
 | 
			
		||||
    port = 6501;
 | 
			
		||||
    # https://github.com/jupyterhub/systemdspawner
 | 
			
		||||
    # Configuration options defined ^
 | 
			
		||||
    extraConfig = ''
 | 
			
		||||
      c.SystemdSpawner.mem_limit = '2G'
 | 
			
		||||
      c.SystemdSpawner.cpu_limit = 1.0
 | 
			
		||||
    '';
 | 
			
		||||
    kernels = {
 | 
			
		||||
      python = {
 | 
			
		||||
        python3 = let
 | 
			
		||||
          env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
 | 
			
		||||
            # Necessary for use as a kernel
 | 
			
		||||
            ipykernel
 | 
			
		||||
 | 
			
		||||
            # Common Python Libraries
 | 
			
		||||
            numpy
 | 
			
		||||
            scipy
 | 
			
		||||
            scikit-learn
 | 
			
		||||
            pandas
 | 
			
		||||
            matplotlib
 | 
			
		||||
            seaborn
 | 
			
		||||
 | 
			
		||||
            # Neural Data Processing Libraries
 | 
			
		||||
            mne-python
 | 
			
		||||
            nibabel
 | 
			
		||||
            neo
 | 
			
		||||
            
 | 
			
		||||
            # Neurosimulators
 | 
			
		||||
            neuronpy
 | 
			
		||||
            nest
 | 
			
		||||
            brian2
 | 
			
		||||
          ]));
 | 
			
		||||
        in {
 | 
			
		||||
          displayName = "Python 3 for Computational Neuroscience";
 | 
			
		||||
          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.caddy.virtualHosts = {
 | 
			
		||||
    "jupyter.ws.kcnhub.com" = {
 | 
			
		||||
      extraConfig = ''
 | 
			
		||||
        reverse_proxy 127.0.0.1:${toString config.services.jupyterhub.port}
 | 
			
		||||
      '';           
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue