Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/reference/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,21 @@ Assorted functions for operating on [Haskell.nix][] data. This is
distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
Infrastructure.

### collectComponents
### collectComponents and collectComponents'

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

This can be used to filter out all test suites or benchmarks of
your project, so that they can be built in Hydra (see check if you
waht to run the tests as well as build them).
want to run the tests as well as build them).

`collectComponents'` is an alias of `collectComponents` without
predicate for filtering.

```
collectComponents =
group: packageSel: haskellPackages: ...
collectComponents' = group: collectComponents (_: true)
```


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

For convenience `$pkg.components.tests` are mapped with this function
to `$pkg.components.checks`.
to `$pkg.checks`.

This function is intended for use with `tests` but it should also work
for `exes` and `benchmarks` if you just want to run them to make sure
Expand Down
9 changes: 9 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ with haskellLib;
(lib.filterAttrs (name: package: (package.isHaskell or false) && packageSel package) haskellPackages))
// { recurseForDerivations = true; };

# Equivalent to collectComponents with (_: true) as selection function.
# Useful for pre-filtered package-set.
#
# For example:
#
# myHaskellPackages = selectProjectPackages hsPkgs;
# myTests = collectComponents' "tests" myHaskellPackages;
collectComponents' = group: collectComponents group (_: true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use something like this in our own codebase as well, so I think this collectComponents' function is a nice addition:

our-exes = collectComponents "exes" (_: true) (selectLocalPackages self.hsPkgs);


# Replacement for lib.cleanSourceWith that has a subDir argument.
inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;

Expand Down