diff --git a/CHANGELOG.md b/CHANGELOG.md index b4deaa0..0500509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/nix/modules/project.nix b/nix/modules/project.nix index cb61054..9bc8b62 100644 --- a/nix/modules/project.nix +++ b/nix/modules/project.nix @@ -84,6 +84,7 @@ in { imports = [ ./project/devshell.nix + ./project/defaults.nix ]; options = { projectRoot = mkOption { diff --git a/nix/modules/project/defaults.nix b/nix/modules/project/defaults.nix new file mode 100644 index 0000000..59d1652 --- /dev/null +++ b/nix/modules/project/defaults.nix @@ -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; + }; + }; + }; +} diff --git a/nix/modules/project/devshell.nix b/nix/modules/project/devshell.nix index 3f9a3fd..a568138 100644 --- a/nix/modules/project/devshell.nix +++ b/nix/modules/project/devshell.nix @@ -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; };