Fix settings.<name>.cabalFlags implementation (#178)

* Fix cabalFlags implementation

* Improve impl; add test

* update changelog

---------

Co-authored-by: Sridhar Ratnakumar <srid@srid.ca>
This commit is contained in:
Berk Özkütük 2023-06-23 21:09:40 +02:00 committed by GitHub
parent dfa5e263a9
commit 57cd506878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -9,7 +9,7 @@
- `flake.haskellFlakeProjectModules`: Dropped all defaults, except the `output` module, which now exports `packages` and `settings`. Added a `defaults.projectModules.output` option that allows the user to override this module, or directly access the generated module.
- Add `project.config.defaults.settings.default` defining sensible defaults for local packages.
- Add `project.config.defaults.enable` to turn off all default settings en masse.
- Regressions in this PR: #169
- Regressions in this PR: #169, #178
## 0.3.0 (May 22, 2023)

View File

@ -199,12 +199,11 @@ in
'';
impl = flags: drv:
let
enabled = lib.filterAttrs (_: v: v) flags;
disabled = lib.filterAttrs (_: v: !v) flags;
enableCabalFlags = fs: drv: builtins.foldl' enableCabalFlag drv fs;
disableCabalFlags = fs: drv: builtins.foldl' disableCabalFlag drv fs;
fns = lib.flip lib.mapAttrsToList flags (flag: enabled:
(if enabled then enableCabalFlag else disableCabalFlag) flag
);
in
lib.pipe drv [ enableCabalFlag disableCabalFlag ];
lib.pipe drv fns;
};
patches = {
type = types.listOf types.path;

View File

@ -52,6 +52,11 @@
# the 'foo' package, we must override it here using `lib.mkForce`.
foo.source = lib.mkForce (inputs.haskell-multi-nix + /foo);
};
settings = {
foo = {
cabalFlags.blah = true;
};
};
devShell = {
tools = hp: {
# Adding a tool should make it available in devshell.