Skip to content

Commit

Permalink
Add back withHoogle support (#1823)
Browse files Browse the repository at this point in the history
* Add hoogle support in flake-parts module

* Update withHoogle documentation
  • Loading branch information
nvmd authored Sep 20, 2023
1 parent 143c27a commit 5f5462d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 27 deletions.
56 changes: 30 additions & 26 deletions Guide/editors.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -214,40 +214,44 @@ To quickly look up function type signatures you can use the built-in hoogle serv

To install it:

1. Open `default.nix`
2. Add `withHoogle = true;` to the `haskellEnv` block, like this:
1. Open `flake.nix`
2. Add `withHoogle = true;` to the `ihp` project block, inside `perSystem` function invocation like this:

```nix
let
ihp = builtins.fetchGit {
url = "https://github.com/digitallyinduced/ihp.git";
ref = "refs/tags/v0.14.0";
};
haskellEnv = import "${ihp}/NixSupport/default.nix" {
ihp = ihp;
haskellDeps = p: with p; [
cabal-install
base
wai
text
hlint
p.ihp
];
otherDeps = p: with p; [
# Native dependencies, e.g. imagemagick
];
projectPath = ./.;
withHoogle = true; # <-------
...
outputs = inputs@{ ihp, flake-parts, systems, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import systems;
imports = [ ihp.flakeModules.default ];
perSystem = { pkgs, ... }: {
ihp = {
enable = true;
projectPath = ./.;
packages = with pkgs; [
# Native dependencies, e.g. imagemagick
];
haskellPackages = p: with p; [
# Haskell dependencies go here
p.ihp
cabal-install
base
wai
text
hlint
];
withHoogle = true; # <-------
};
};
};
in
haskellEnv
```

Run `devenv up` to remake your dev environment.

After that you can use the following command to start hoogle at `localhost:8080`:

```bash
nix-shell --run 'hoogle server --local -p 8080'
hoogle server --local -p 8080
```
12 changes: 11 additions & 1 deletion flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ ihpFlake:
type = lib.types.path;
};

withHoogle = lib.mkOption {
description = ''
Enable Hoogle support. Adds `hoogle` command to PATH.
'';
type = lib.types.bool;
default = false;
};

dontCheckPackages = lib.mkOption {
description = ''
List of Haskell package names whose tests are skipped during build.
Expand Down Expand Up @@ -166,7 +174,9 @@ ihpFlake:
containers = lib.mkForce {};

languages.haskell.enable = true;
languages.haskell.package = ghcCompiler.ghc.withPackages cfg.haskellPackages;
languages.haskell.package = (if cfg.withHoogle
then ghcCompiler.ghc.withHoogle
else ghcCompiler.ghc.withPackages) cfg.haskellPackages;

languages.haskell.languageServer = ghcCompiler.haskell-language-server;
languages.haskell.stack = null; # Stack is not used in IHP
Expand Down

0 comments on commit 5f5462d

Please sign in to comment.