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. - `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.settings.default` defining sensible defaults for local packages.
- Add `project.config.defaults.enable` to turn off all default settings en masse. - 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) ## 0.3.0 (May 22, 2023)

View File

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

View File

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