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.

codygman

@tristanC you might like direnv-mode and the cached use_nix variant or lorri if the nix-shell command blocks too long

tristanC

@codygman Thanks, I did tried direnv and nix-direnv, but it is still too slow when switching between buffer from different project and I prefer manually running the nix-shell function from the nix-mode when necessary.

tristanC

Also since that initial expression, I am now also using nix to manage the IDE configuration: https://github.com/podenv/devenv

Contribute to podenv/devenv development by creating an account on GitHub.