(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