I am trying to get a persistent jupyterhub/lab up and running on nixos. I have made progress, but stuck on two items. First, is it possible in the approach I am using to add jupyterlab extensions declaratively? I saw that its possible if I build specific shells and do my coding only inside those purpose built shells, but I would rather not take that approach. Second, while I got a python env up and running with some basic data science packages to try out, I can’t get an R environment to work. Console won’t connect to the kernel, even after multiple attempts and trying to build the env and the argv different ways, including finding and using the full path to the R bin. Pasting my code below, if anyone has pointers who may have tried this. Thanks!
{ config, lib, pkgs, ... }:
{
services.jupyterhub = {
enable = true;
jupyterhubEnv = pkgs.python311.withPackages (p: with p; [
jupyterhub
jupyterhub-systemdspawner
pip
ipython
jupyter
notebook
ipykernel
]);
jupyterlabEnv = pkgs.python311.withPackages (p: with p; [
jupyterhub
jupyterlab
pip
ipython
jupyter
notebook
ipykernel
]);
kernels = {
python311 = let
env = (pkgs.python311.withPackages (python311Packages: with python311Packages; [
ipykernel
pandas
scikit-learn
numpy
seaborn
matplotlib
scipy
]));
in {
displayName = "Python 3 for ML";
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";
};
R = let
env = (pkgs.rWrapper.override {
packages = with pkgs.rPackages; [
IRkernel
tidyverse
caret
randomForest
tidymodels
purrr
shiny
data_table
jsonlite
];
});
in {
displayName = "R for ML";
argv = [
"/nix/store/pqynpqccbr41zz3pg844qiq2h87mxhwx-R-4.3.2-wrapper/bin/R"
"--slave"
"-e"
"IRkernel::main()"
"--args"
"{connection_file}"
];
language = "R";
logo32 = "${env.sitePackages}/IRKernel/resources/logo-32x32.png";
logo64 = "${env.sitePackages}/IRkernel/resources/logo-64x64.png";
};
};
};
}