@@ -73,7 +73,7 @@ components = {
7373 all = COMPONENT;
7474}
7575```
76−
76+
7777## Component
7878
7979In [Haskell.nix][], a _component_ is a derivation corresponding to a
@@ -104,7 +104,7 @@ set. They are either:
104104If using the function form of a module, the following named parameters
105105will be passed to it:
106106
107−| Argument | Type | Description |
107+| Argument | Type | Description |
108108|------------------|------|---------------------|
109109| `haskellLib` | attrset | The [haskellLib](#haskelllib) utility functions. |
110110| `pkgs` | | The Nixpkgs collection. |
@@ -126,7 +126,7 @@ mkStackPkgSet =
126126 { stack-pkgs, pkg-def-extras ? [], modules ? []}: ...
127127```
128128
129−| Argument | Type | Description |
129+| Argument | Type | Description |
130130|------------------|------|---------------------|
131131| `stack-pkgs` | | `import ./pkgs.nix` — The imported file generated by `stack‑to‑nix`. |
132132| `pkg‑def‑extras` | List of [Extras](#extras) | For overriding the package set. |
@@ -144,7 +144,7 @@ mkCabalProjectPkgSet =
144144 { plan-pkgs, pkg-def-extras ? [], modules ? []}: ...
145145```
146146
147−| Argument | Type | Description |
147+| Argument | Type | Description |
148148|------------------|------|---------------------|
149149| `plan-pkgs` | | `import ./pkgs.nix` — The imported file generated by `plan‑to‑nix`. |
150150| `pkg‑def‑extras` | List of [Extras](#extras) | For overriding the package set. |
@@ -192,6 +192,46 @@ Assorted functions for operating on [Haskell.nix][] data. This is
192192distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
193193Infrastructure.
194194
195+### collectComponents
196+
197+Extracts a selection of components from a Haskell [package set](#package-set).
198+
199+This can be used to filter out all test suites or benchmarks of
200+your project, so that they can be built in Hydra.
201+
202+```
203+collectComponents =
204+ group: packageSel: haskellPackages: ...
205+```
206+
207+
208+| Argument | Type | Description |
209+|-------------------|--------|---------------------|
210+| `group` | String | A [sub-component type](#subComponentTypes). |
211+| `packageSel` | A function `Package -> Bool` | A predicate to filter packages with. |
212+| `haskellPackages` | [Package set](#package-set) | All packages in the build. |
213+
214+**Return value**: a recursive attrset mapping package names → component names → components.
215+
216+**Example**:
217+
218+```nix
219+tests = collectComponents "tests" (package: package.identifier.name == "mypackage") hsPkgs;
220+```
221+
222+Will result in moving derivations from `hsPkgs.mypackage.components.tests.unit-tests`
223+to `tests.mypackage.unit-tests`.
224+
225+#### subComponentTypes
226+
227+Sub-component types identify [components](#component) and are one of:
228+
229+ - `sublibs`
230+ - `foreignlibs`
231+ - `exes`
232+ - `tests`
233+ - `benchmarks`
234+
195235# Package-set functions
196236
197237These functions exist within the `hsPkgs` package set.
@@ -208,7 +248,7 @@ shellFor =
208248```
209249
210250
211−| Argument | Type | Description |
251+| Argument | Type | Description |
212252|----------------|------|---------------------|
213253| `packages` | Function | Package selection function. It takes a list of [Haskell packages](#haskell-package) and returns a subset of these packages. |
214254| `withHoogle` | Boolean | Whether to build a Hoogle documentation index and provide the `hoogle` command. |