How to override/set `jupyterlabWith` `extraPackages` from default.nix in shell.nix?

I’ve got the following shell.nix:

{ pkgs ? import
    (
      fetchTarball {
        name = "21.11";
        url = "https://github.com/NixOS/nixpkgs/archive/a7ecde854aee5c4c7cd6177f54a99d2c1ff28a31.tar.gz";
        sha256 = "162dywda2dvfj1248afxc45kcrg83appjd0nmdb541hl7rnncf02";
      })
    { }
, jupyter ? import
    (
      builtins.fetchGit {
        url = https://github.com/tweag/jupyterWith;
        rev = "afea17cd4b8fe417cb6b83dc240dec02a7d1d92c";
      })
    { }
}:
let
  bashKernel = jupyter.kernels.bashKernel { };

  jupyterEnvironment = jupyter.jupyterlabWith {
    kernels = [ bashKernel ];
    extraPackages = _: [
      pkgs.nixpkgs-fmt
    ];
  };
in
jupyterEnvironment.env

I’d like to split this into a default.nix without extraPackages and a shell.nix which creates a shell with the Jupyter environment with nixpkgs-fmt in extraPackages. How do I do that? The closest I’ve got is to pass extraPackages as a parameter to default.nix, but that’s hacky: default.nix shouldn’t change to accommodate shell.nix.