Skip to content

Commit e346ccb

Browse files
authored
Equivalent to collectComponents with (_: true) as selection function (#438)
* Add collectComponents': collectComponents with (_: true) as selection function. * Fix location of checks in documentation.
1 parent b09db52 commit e346ccb

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

docs/reference/library.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,21 @@ Assorted functions for operating on [Haskell.nix][] data. This is
281281
distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
282282
Infrastructure.
283283

284-
### collectComponents
284+
### collectComponents and collectComponents'
285285

286286
Extracts a selection of components from a Haskell [package set](#package-set).
287287

288288
This can be used to filter out all test suites or benchmarks of
289289
your project, so that they can be built in Hydra (see check if you
290-
waht to run the tests as well as build them).
290+
want to run the tests as well as build them).
291+
292+
`collectComponents'` is an alias of `collectComponents` without
293+
predicate for filtering.
291294

292295
```
293296
collectComponents =
294297
group: packageSel: haskellPackages: ...
298+
collectComponents' = group: collectComponents (_: true)
295299
```
296300

297301

@@ -321,7 +325,7 @@ This function turns a derivation that builds a test into one to run it.
321325
| `drv` | Derivation | One of `$pkg.components.tests.$test`. |
322326

323327
For convenience `$pkg.components.tests` are mapped with this function
324-
to `$pkg.components.checks`.
328+
to `$pkg.checks`.
325329

326330
This function is intended for use with `tests` but it should also work
327331
for `exes` and `benchmarks` if you just want to run them to make sure

lib/default.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ with haskellLib;
143143
(lib.filterAttrs (name: package: (package.isHaskell or false) && packageSel package) haskellPackages))
144144
// { recurseForDerivations = true; };
145145

146+
# Equivalent to collectComponents with (_: true) as selection function.
147+
# Useful for pre-filtered package-set.
148+
#
149+
# For example:
150+
#
151+
# myHaskellPackages = selectProjectPackages hsPkgs;
152+
# myTests = collectComponents' "tests" myHaskellPackages;
153+
collectComponents' = group: collectComponents group (_: true);
154+
146155
# Replacement for lib.cleanSourceWith that has a subDir argument.
147156
inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;
148157

0 commit comments

Comments
 (0)