Skip to content

Commit

Permalink
add option haskellTools for vanilla GHC shell tools
Browse files Browse the repository at this point in the history
  • Loading branch information
tek committed Oct 3, 2023
1 parent 1a6e042 commit 2b4d5e7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Unreleased

* Add the option `haskellTools` globally and per-env, which allows specifying shell tools that should be made available
from the env's GHC without overrides.

# 0.6.7

* The option `hackage.add` allows changed files to be git-added, but not committed, during release when `hackage.commit`
Expand Down
12 changes: 12 additions & 0 deletions modules/basic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ in {
'';
};

haskellTools = mkOption {
description = mdDoc ''
Function returning a list of names of Haskell packages that should be included in every environment's `$PATH`.
This is a convenience variant of [](#opt-env-buildInputs) that provides the environment's GHC package set (without
overrides) as a function argument.
This is intended for tooling like `fourmolu`.
'';
type = functionTo (listOf package);
default = _: [];
example = literalExpression ''ghc: [ghc.fourmolu]'';
};

pkgs = mkOption {
type = util.types.pkgs;
description = mdDoc ''
Expand Down
14 changes: 14 additions & 0 deletions modules/env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ let
buildInputs =
mkBuildInputs config.buildInputs ++
mkBuildInputs global.buildInputs ++
config.haskellTools config.ghc.vanillaGhc ++
global.haskellTools config.ghc.vanillaGhc ++
optional config.hls.enable config.hls.package ++
optional config.ghcid.enable config.ghcid.package ++
[ghcWithPackages]
Expand Down Expand Up @@ -253,6 +255,18 @@ in {
default = [];
};

haskellTools = mkOption {
description = mdDoc ''
Function returning a list of names of Haskell packages that should be included in the environment's `$PATH`.
This is a convenience variant of [](#opt-env-buildInputs) that provides the environment's GHC package set (without
overrides) as a function argument.
This is intended for tooling like `fourmolu`.
'';
type = functionTo (listOf package);
default = _: [];
example = literalExpression ''ghc: [ghc.fourmolu]'';
};

localDeps = mkOption {
description = mdDoc "Whether to add the dependencies of the project's local packages to GHC's package db.";
type = bool;
Expand Down
4 changes: 4 additions & 0 deletions test/basic/root/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
test.enable = true;
};
cabal.dependencies = ["base" "some"];
envs.dev.haskellTools = g: [g.fourmolu];
envs.dev.overrides = {hackage, ...}: {
fourmolu = hackage "0.14.0.0" "1bhfx6j79hc32q22c7dagirby5j5dhydm0cm9av7dhhjd71rr2xk";
};
};
}
4 changes: 4 additions & 0 deletions test/basic/test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
nix build .#ghc92-root
check 'result/bin/root' 'string' 'Running the main package produced the wrong output'
target='fourmolu 0.11.0.0
using ghc-lib-parser 9.4.6.20230808'
check 'nix develop -c fourmolu --version' $target 'Fourmolu version output wrong'
'';
}

0 comments on commit 2b4d5e7

Please sign in to comment.