I'm trying to use hoogle in a Haskell development environment exactly like the one described by O'Charles' wiki:
I have modified shell.nix
like below in order to use hoogleLocal
, but it doesn't seem to install the hoogle binary for me.
let
pkgs = import <nixpkgs> {};
# I'm attempting to use hoogle here, but it is not working.
haskellPackages =
let callPackage = pkgs.lib.callPackageWith haskellPackages;
in pkgs.recurseIntoAttrs (pkgs.haskellPackages.override {
extension = self: super: {
thiscurrentpackage = self.callPackage ./. {};
hoogleLocal = pkgs.haskellPackages.hoogleLocal.override {
packages = self.thiscurrentpackage;
};
};
});
in pkgs.myEnvFun {
name = haskellPackages.thiscurrentpackage.name;
buildInputs = [
(haskellPackages.ghcWithPackages (hs: ([
hs.cabalInstall
hs.ghcMod
hs.yesodBin
# This doesn't appear to install the hoogle binary?
hs.hoogleLocal
] ++ hs.thiscurrentpackage.propagatedNativeBuildInputs)))
];
}
In the resulting shell, the hoogle
binary is not available.
If I include hs.hoogle
to the buildInputs
, the hoogle
binary is installed but it can't find the databases. Below is what happens when I try to use it.
$ nix-shell
......
$ hoogle Monad
Could not find some databases: default
Searching in:
.
/nix/store/91y9q2y5a2ws8xgcsx1gkhfagc0f2qz6-haskell-hoogle-ghc7.8.3-4.2.36-shared/share/x86_64-linux-ghc-7.8.3/hoogle-4.2.36/databases
There are no available databases, generate them with: hoogle data
$ hoogle data
hoogle: /nix/store/91y9q2y5a2ws8xgcsx1gkhfagc0f2qz6-haskell-hoogle-ghc7.8.3-4.2.36-shared/share/x86_64-linux-ghc-7.8.3/hoogle-4.2.36/databases:
changeWorkingDirectory: does not exist (No such file or directory)
$
How do I get this working correctly for a setup like described by O'Charles?
Edit: The original shell.nix is the same one from this answer.
Here's what my Nix Haskell dev environment looks like
in
~/.nixpkgs/config.nix
:The environment helper function
First off, define a haskellEnvFun function for building Haskell environments:
Defining some environments
Call this function to define two environments: one for running the Hoogle builder on changes, and one without:
Packages
Define all the packages you want to use in your local Haskell dev environment:
Shell helpers
In your
~/.profile
define a couple bash functions to load those environments for convenience:Hoogle
Call
haskell-env-hoogle
in your shell. This will build all of your packages + docs and load you into an environment withhoogle
in scope. At this point I usually type:to launch a hoogle server the the background. Eventually I want to have a systemd service for this so that I can just nixos-rebuild to regen docs and launch the server automatically.
Emacs
For emacs I've set the
haskell-hoogle-url
tohttp://localhost:8080/?hoogle=%s
, so that I can get local hoogle docs for keywords under my cursor. I use spacemacs so I just type, h h
for this functionality.You can see my full nixpkgs config here: https://github.com/jb55/nix-files/blob/659798f2ca81fb7ad0cb5a29de576024ee16eef8/nixpkgs/config.nix#L20
Hope that helps.