From 5f5462dd3013d983cc9c34d0359d24eed432a0f2 Mon Sep 17 00:00:00 2001 From: nvmd Date: Wed, 20 Sep 2023 20:07:45 +0300 Subject: [PATCH] Add back withHoogle support (#1823) * Add hoogle support in flake-parts module * Update withHoogle documentation --- Guide/editors.markdown | 56 ++++++++++++++++++++++-------------------- flake-module.nix | 12 ++++++++- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/Guide/editors.markdown b/Guide/editors.markdown index 992ca8764..26f78b3c4 100644 --- a/Guide/editors.markdown +++ b/Guide/editors.markdown @@ -214,34 +214,38 @@ 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. @@ -249,5 +253,5 @@ 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 ``` diff --git a/flake-module.nix b/flake-module.nix index 50a14e208..5cdd568e5 100644 --- a/flake-module.nix +++ b/flake-module.nix @@ -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. @@ -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