Feedback on customizing jupyter kernels for Quarto

I’ve been playing around with a reproducible setup for Quarto, a general purpose literate programming framework combining pandoc with jupyter. I wanted to see if I could make a project with Quarto that supported jupyter kernels that are less commonly used (rust and clojure).

I was able to get something working here that I’m reasonably happy with. I’m both able to (1) extend jupyter with customized kernels and (2) provided these kernels to quarto through overrides. I’m pretty new to development with nix, so I’m interested in any feed back on the demo. But in particular I’m wondering if there’s a more idiomatic way to accomplish my override for quarto.

Basically, I found that if I changed the environment variable QUARTO_PYTHON to point at my customized jupyter, then quarto would use the kernels I wanted (by default it only sees the builtin python3 kernel of nixpkgs). But to actually accomplish this in my derivation was a bit of a hack:

# ...
quarto = (pkgs.quarto.override { python3 = null; }).overrideAttrs (
    final: prev: {
    preFixup =
        let
        inherit (builtins) stringLength substring;
        pfix = prev.preFixup;
        plen = (stringLength pfix);
        pfix_sub = substring 0 (plen - 1) pfix;
        in
        pfix_sub + "--prefix QUARTO_PYTHON : ${jupyter}/bin/python3";
    }
);
# ...

This was after looking at the quarto definition on nixpkgs and seeing where QUARTO_PYTHON was being defined by default. But to actually override the default I messed with the preFixup attr from the original derviation. It all works so I guess it’s fine, but I’m wondering if there’s a cleaner way to do this?

Thanks for any feedback :grinning: