diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a80ba1..b9b93ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - #64: Remove hlintCheck (use [treefmt-nix](https://github.com/numtide/treefmt-nix#flake-parts) instead) - #52: Expose the final package set as `finalPackages`. Rename `haskellPackages`, accordingly, to `basePackages`. Overlays are applied on top of `basePackage` -- using `source-overrides`, `overrides`, `packages` in that order -- to produce `finalPackages`. - #68: You can now use `imports` inside of `haskellProjects.` to modularize your Haskell project configuration. + - #79: `flake.haskellFlakeProjectModules.` option can be used to set and expose your Haskell project modules to other flakes. - #67: `overrides` will be combined using `composeManyExtensions`, however their order is arbitrary. This is an experimental feature, and a warning will be logged. ## 0.1.0 diff --git a/flake-module.nix b/flake-module.nix index 742034d..6f0d86a 100644 --- a/flake-module.nix +++ b/flake-module.nix @@ -239,9 +239,20 @@ in }; in { - options.haskellProjects = mkOption { - description = "Haskell projects"; - type = types.attrsOf projectSubmodule; + options = { + haskellProjects = mkOption { + description = "Haskell projects"; + type = types.attrsOf projectSubmodule; + }; + + haskellFlakeProjectModules = mkOption { + type = types.lazyAttrsOf types.deferredModule; + default = { }; + description = '' + An attrset of `haskellProjects.` modules that can be imported in + other flakes. + ''; + }; }; config = diff --git a/test/flake.nix b/test/flake.nix index 9f8c253..7447162 100644 --- a/test/flake.nix +++ b/test/flake.nix @@ -22,29 +22,26 @@ inputs.haskell-flake.flakeModule inputs.check-flake.flakeModule ]; + flake.haskellFlakeProjectModules.default = { pkgs, ... }: { + overrides = self: super: { + # This is purposefully incorrect (pointing to ./.) because we + # expect it to be overriden in perSystem below. + foo = self.callCabal2nix "foo" ./. { }; + }; + devShell = { + tools = hp: { + # Setting to null should remove this tool from defaults. + ghcid = null; + }; + hlsCheck.enable = true; + }; + }; perSystem = { self', pkgs, ... }: { haskellProjects.default = { # Multiple modules should be merged correctly. - imports = - let - defaults = { - overrides = self: super: { - # This is purposefully incorrect (pointing to ./.) because we - # expect it to be overriden below. - foo = self.callCabal2nix "foo" ./. { }; - }; - devShell = { - tools = hp: { - # Setting to null should remove this tool from defaults. - ghcid = null; - }; - hlsCheck.enable = true; - }; - }; - in - [ defaults ]; + imports = [ self.haskellFlakeProjectModules.default ]; overrides = self: super: { - # This overrides the overlay above (in `defaults`), because the + # This overrides the overlay above (in `flake.*`), because the # module system merges them in such order. cf. the WARNING in option # docs. foo = self.callCabal2nix "foo" (inputs.haskell-multi-nix + /foo) { };