Nix-shell fails: Head of "shell_variables" is not a function context

(Retrying to get a solution to this here)
I am trying to create a shell.nix for a project which uses various tools. Among the tools needed in the shell is a program written in Haskell (pandoc-theorem), which is available on GitHub (I have my own fork and some patches to it). My understanding is that I need a Nix Expression for this program which uses pkgs.haskellPackages.developPackage along with pkgs.fetchFromGitHub to fetch and build this for the shell. This expression will be put in a file, then the shell.nix file imports this expression and adds it the buildInputs parameter of of mkShell.

I have created the two files, and attempted to nix-shell to test that I get access to the tool. I can build using nix-build, which creates the compiled executable and puts it in the “result” directory. But I wanted to bundle this package together with a whole set for a project using nix-shell.

Unfortunately running nix-shell fails with the error:

bash: /nix/store/1pbyswvdf5q4yrm4qjkk15ij0fi3bs6c-ghc-9.4.8-with-packages: Is a directory
bash: pop_var_context: head of "shell_variables" is not a function context
bash: pop_var_context: head of "shell_variables" is not a function context

What is the source of this error? I must have misunderstood something about how to build the Haskell project and import into nix-shell, but I don’t really know where to start unwinding this. I have included the details below. In advance, thanks for any pointers in the right direction.

Listings

pandoc-theorem.nix:

{ pkgs ? import <nixpkgs> {} } :
let
  pandocTheoremSrc = pkgs.fetchFromGitHub {
    owner = "typeterrorist";
    repo = "pandoc-theorem";
    rev = "d2fc223f";
    sha256 = "sha256-rvS+pZro3KkFgdgBxKkVDeJJa8WW2zk59ExooIAb7C0=";
    };
in
 pkgs.haskellPackages.developPackage {
  name = "pandoc-theorem";
  root = pandocTheoremSrc;
  modifier = drv:
      pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
        [ cabal-install
          ghcid
        ]);
}

shell.nix:

{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  buildInputs = [
    (import ./pandoc-theorem.nix { inherit pkgs; })
  ];
}

Attempting to run nix-shell in the directory with shell.nix and pandoc-theorem.nix in it:

$ nix-shell
bash: /nix/store/1pbyswvdf5q4yrm4qjkk15ij0fi3bs6c-ghc-9.4.8-with-packages: Is a directory
bash: pop_var_context: head of "shell_variables" is not a function context
bash: pop_var_context: head of "shell_variables" is not a function context

No hints?
I am stomped at how to even start debugging this.

I believe it is related to this issue: bash: 5.1 -> 5.2, readline: 8.1 -> 8.2 by kaldonir · Pull Request #207083 · NixOS/nixpkgs · GitHub

head of "shell_variables" is not a function context is a meaningless error.
The actual error is whatever comes before that, which to me indicates that the builder is getting used incorrectly. (Though I’m not familiar with haskell builders like developPackage to point out the error exactly.)

Thanks, I suspected as much. It must be some case of using it wrong, but I can’t find any examples which hints at how to do it right. I was hoping someone with experience with the Haskell builders would see this, and point in the right direction.