Enable specifying the default devShell.tools

This commit is contained in:
Sridhar Ratnakumar 2023-04-28 16:11:32 -04:00 committed by Sridhar Ratnakumar
parent fb1a3c32a8
commit 98dfcc619b
4 changed files with 34 additions and 11 deletions

View File

@ -9,6 +9,7 @@
- #151: Use `lib.getBin` to get the bin output
- #148: Remove automatic hpack->cabal generation. Use `pre-commit-hooks.nix` instead.
- #149: Fix unnecessary re-runs of cabal2nix evaluation. Add a `debug` option to have haskell-flake produce diagnostic messages.
- #153: Add `config.defaults` submodule to allow overriding the default devShell tools added by haskell-flake
## 0.2.0 (Mar 13, 2023)

View File

@ -84,6 +84,7 @@ in
{
imports = [
./project/devshell.nix
./project/defaults.nix
];
options = {
projectRoot = mkOption {

View File

@ -0,0 +1,24 @@
# A module representing the default values used internally by haskell-flake.
{ lib, ... }:
let
inherit (lib)
mkOption
types;
inherit (types)
functionTo;
in
{
options.defaults = {
devShell.tools = mkOption {
type = functionTo (types.attrsOf (types.nullOr types.package));
description = ''Build tools always included in devShell'';
default = hp: with hp; {
inherit
cabal-install
haskell-language-server
ghcid
hlint;
};
};
};
}

View File

@ -20,11 +20,12 @@ let
type = functionTo (types.attrsOf (types.nullOr types.package));
description = ''
Build tools for developing the Haskell project.
These tools are merged with the haskell-flake defaults defined in the
`defaults.devShell.tools` option. Set the value to `null` to remove
that default tool.
'';
default = hp: { };
defaultText = ''
Build tools useful for Haskell development are included by default.
'';
};
extraLibraries = mkOption {
type = functionTo (types.attrsOf (types.nullOr types.package));
@ -83,14 +84,10 @@ in
let
inherit (config.outputs) finalPackages;
defaultBuildTools = hp: with hp; {
inherit
cabal-install
haskell-language-server
ghcid
hlint;
};
nativeBuildInputs = lib.attrValues (defaultBuildTools finalPackages // config.devShell.tools finalPackages);
nativeBuildInputs = lib.attrValues (
config.defaults.devShell.tools finalPackages //
config.devShell.tools finalPackages
);
mkShellArgs = config.devShell.mkShellArgs // {
nativeBuildInputs = (config.devShell.mkShellArgs.nativeBuildInputs or [ ]) ++ nativeBuildInputs;
};