haskellPackages.shellFor withHoogle is great! - Nix

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

tristanC

Shoutout to nixpkgs! I was trying to get a local hoogle with haddock documentation, and after trying without luck stack then cabal I finally gave nix a serious try and it is working well so far. In particular it let me re-use the same dependencies across projects and the hoogle service correctly cross reference libraries documentation.

Though I struggled with using ghc.withHoogle until I found the shellFor function, for reference here is the default.nix

{ nixpkgs ? import <nixpkgs> { } }:
let
  name = "hadertoy";
  drv = nixpkgs.haskellPackages.callCabal2nix name ./. { };
  shellDrv = nixpkgs.haskellPackages.shellFor {
    withHoogle = true;
    packages = p: [ drv ];
    buildInputs = with nixpkgs.haskellPackages; [ hlint ghcid cabal-install ];
  };
in if nixpkgs.lib.inNixShell then shellDrv else drv

The command to start hoogle is: nix-shell --command "hoogle server -p 8080 --local --haskell". Then for emacs, using the M-x nix-shell function from nix-mode makes flycheck and run-haskell use the right env without fuss.