Jupyterlab and an R env

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";
  };
};
};
}

Im pretty sure absolute paths to the nix store dont work. Maybe you should use ${pkgs.R}/bin/R instead of "/nix/store/pqynpqccbr41zz3pg844qiq2h87mxhwx-R-4.3.2-wrapper/bin/R"

I was able to get the R environment to load by using {env}/bin/R. So this is partially solved. One remaining challenge is loading non-python packages in the underlying jupyterhub/lab environment. Jupyterlab-git needs regular git installed, which it obviously is on the base system, but the jupyterhub/lab environment for some reason can’t see it. I must need to load it into the hub/lab environment. They are built like this:

jupyterhubEnv = pkgs.python311.withPackages (p: with p; [
    jupyterhub
    jupyterhub-systemdspawner
    pip
    ...

It appears you can only load python packages into the underlying environment. Is there a way to load non python packages, such as git?