Skip to content

Commit 70f01c2

Browse files
ElvishJerriccoangerman
authored andcommitted
Use mkForce in with-package test, and add a comment about the quirk.
1 parent 17ead94 commit 70f01c2

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

modules/package.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,15 @@ in {
284284
};
285285
};
286286

287+
# This has one quirk. Manually setting options on the all component
288+
# will be considered a conflict. This is almost always fine; most
289+
# settings should be modified in either the package options, or an
290+
# individual component's options. When this isn't sufficient,
291+
# mkForce is a reasonable workaround.
292+
#
293+
# An alternative solution to mkForce for many of the options where
294+
# this is relevant would be to switch from the bool type to
295+
# something like an anyBool type, which would merge definitions by
296+
# returning true if any is true.
287297
config.components.all = lib.mkMerge (haskellLib.getAllComponents config);
288298
}

test/with-packages/default.nix

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let
2525
# vary component config for tests
2626
{
2727
packages.test-with-packages.components = {
28-
all.doExactConfig = false; # the default
28+
all.doExactConfig = mkForce false; # the default; use force because of quirk in all. See package.nix
2929
library.doExactConfig = true; # not the default
3030
};
3131
}
@@ -68,14 +68,15 @@ in
6868
'';
6969

7070
meta.platforms = platforms.all;
71-
} // {
72-
# Used for debugging with nix repl
73-
inherit packages pkgSet;
71+
passthru = {
72+
# Used for debugging with nix repl
73+
inherit packages pkgSet;
7474

75-
# Used for testing externally with nix-shell (../tests.sh).
76-
# This just adds cabal-install to the existing shells.
77-
test-shell = addCabalInstall packages.test-with-packages.components.all;
75+
# Used for testing externally with nix-shell (../tests.sh).
76+
# This just adds cabal-install to the existing shells.
77+
test-shell = addCabalInstall packages.test-with-packages.components.all;
7878

79-
# A variant of test-shell with the component option doExactConfig enabled
80-
test-shell-dec = addCabalInstall packages.test-with-packages.components.library;
79+
# A variant of test-shell with the component option doExactConfig enabled
80+
test-shell-dec = addCabalInstall packages.test-with-packages.components.library;
81+
};
8182
}

0 commit comments

Comments
 (0)