-
Notifications
You must be signed in to change notification settings - Fork 19
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
Changes from 2 commits
8b47c6a
e801239
a8b62cc
24d19db
a98024f
112b9e4
b715aa3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ config, lib, flake-parts-lib, ... }: | ||
let | ||
inherit (lib) | ||
mkOption | ||
types | ||
; | ||
inherit (flake-parts-lib) | ||
mkTransposedPerSystemModule | ||
; | ||
in | ||
mkTransposedPerSystemModule { | ||
name = "haskellFlakeProjectModules"; | ||
option = mkOption { | ||
type = types.lazyAttrsOf types.deferredModule; | ||
default = { }; | ||
description = '' | ||
''; | ||
}; | ||
file = ./project-module.nix; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,26 +23,23 @@ | |
inputs.check-flake.flakeModule | ||
]; | ||
perSystem = { self', pkgs, ... }: { | ||
haskellFlakeProjectModules.default = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @roberth I must say I'm not happy with this flake-parts module now providing two (not one) top-level options -- A single top-level would make sense. Like: {
haskellFlake = {
projectModules = { .. };
projects.default = { .. };
};
} It also makes the option name obvious enough to indicate that it comes from wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OTOH, the current way of naming it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need options in two separate locations anyway. See previous comment https://github.com/srid/haskell-flake/pull/79/files#r1103655549
Flat attributes is probably the way to go. I've made an exception for |
||
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; | ||
}; | ||
}; | ||
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 | ||
# module system merges them in such order. cf. the WARNING in option | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think using the local
pkgs
is the right thing to do. It should come from the environment where it's imported, so all we can really need to do isflake.haskellFlakeProjectModules.foo = { pkgs, ... }: { overrides = f pkgs; };
.If a flake does need to reference packages it defines, it can do so with
getSystem
and the like.