on iko/ghcjs-patch-master help sign in
Equivalent to collectComponents with (_: true) as selection function (#438)
e346ccbJean-Baptiste Giraudeau
docs/reference/library.md+7−3
@@ -281,17 +281,21 @@ Assorted functions for operating on [Haskell.nix][] data. This is
281distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
281distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
282Infrastructure.
282Infrastructure.
283
283
284−### collectComponents
284+### collectComponents and collectComponents'
285
285
286Extracts a selection of components from a Haskell [package set](#package-set).
286Extracts a selection of components from a Haskell [package set](#package-set).
287
287
288This can be used to filter out all test suites or benchmarks of
288This can be used to filter out all test suites or benchmarks of
289your project, so that they can be built in Hydra (see check if you
289your 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.
291
294
292```
295```
293collectComponents =
296collectComponents =
294 group: packageSel: haskellPackages: ...
297 group: packageSel: haskellPackages: ...
298+collectComponents' = group: collectComponents (_: true)
295```
299```
296
300
297
301
@@ -321,7 +325,7 @@ This function turns a derivation that builds a test into one to run it.
321| `drv` | Derivation | One of `$pkg.components.tests.$test`. |
325| `drv` | Derivation | One of `$pkg.components.tests.$test`. |
322
326
323For convenience `$pkg.components.tests` are mapped with this function
327For convenience `$pkg.components.tests` are mapped with this function
324−to `$pkg.components.checks`.
328+to `$pkg.checks`.
325
329
326This function is intended for use with `tests` but it should also work
330This function is intended for use with `tests` but it should also work
327for `exes` and `benchmarks` if you just want to run them to make sure
331for `exes` and `benchmarks` if you just want to run them to make sure
lib/default.nix+9
@@ -143,6 +143,15 @@ with haskellLib;
143 (lib.filterAttrs (name: package: (package.isHaskell or false) && packageSel package) haskellPackages))
143 (lib.filterAttrs (name: package: (package.isHaskell or false) && packageSel package) haskellPackages))
144 // { recurseForDerivations = true; };
144 // { recurseForDerivations = true; };
145
145
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+
146 # Replacement for lib.cleanSourceWith that has a subDir argument.
155 # Replacement for lib.cleanSourceWith that has a subDir argument.
147 inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;
156 inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;
148
157