haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

Modules ignored for shell tools

Open nc6 opened this issue 3 years ago • 1 comments

As per https://github.com/input-output-hk/haskell.nix/blob/master/overlays/tools.nix#L38, a shell tool should accept a modules argument which gets passed to cabalProject. However, as far as I can tell, this argument is entirely ignored - it can contain entirely spurious code without any errors, and has no impact on the build.

Example of failing usage:

                shell.tools = {
                  cabal = { };
                  hlint = { };
                  haskell-language-server = {
                    version = "latest";
                    modules = [{
                      pkgs.haskell-language-server.flags.haddockComments = false;
                    }];
                  };
                  ormolu = { };
                };

nc6 avatar Jun 07 '22 07:06 nc6

modules are applied late in the process after the cabal solver has been used to pick a plan. modules can sometime be safely used to override flags chosen by cabal (in particular if they do not affect the set of packages needed in the plan). A better option in most cases is to tell cabal what flags should be so that the plan.json is constructed.

To do that for tools coming from hackage we need to provide a cabal.project file. Try:

                shell.tools = {
                  cabal = { };
                  hlint = { };
                  haskell-language-server = {
                    version = "latest";
                    cabalProject = ''
                      packages: .
                      package haskell-language-server
                        flags: +haddockComments
                    '';
                  };
                  ormolu = { };
                };

hamishmack avatar Jun 08 '22 01:06 hamishmack

Closing. Please reopen if using cabalProject does not work. I think cabalProjectLocal also works for tools now, so you could also use:

                shell.tools = {
                  cabal = { };
                  hlint = { };
                  haskell-language-server = {
                    version = "latest";
                    cabalProjectLocal = ''
                      package haskell-language-server
                        flags: +haddockComments
                    '';
                  };
                  ormolu = { };
                };

hamishmack avatar Sep 29 '22 06:09 hamishmack