Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add haskellFlakeProjectModules option #79

Merged
merged 7 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<name>` to modularize your Haskell project configuration.
- #79: `flake.haskellFlakeProjectModules.<name>` 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
Expand Down
17 changes: 14 additions & 3 deletions flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.<name>` modules that can be imported in
other flakes.
'';
};
};

config =
Expand Down
35 changes: 16 additions & 19 deletions test/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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) { };
Expand Down