Skip to content

Commit 711d6e1

Browse files
committed
Add project.projectVariant that apply flake.variants modules
1 parent ea40f5c commit 711d6e1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/reference/library.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ Then feeding its result into [mkCabalProjectPkgSet](#mkcabalprojectpkgset) passi
166166
| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
167167
| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
168168
| `projectCross` | Attrset | Like `pkgs.pkgsCross.<system>` from nixpkgs `p.projectCross.<system>` returns the project results for cross compilation (where system is a member of nixpkgs lib.systems.examples). So `p.projectCross.ghcjs.hsPkgs` is the same as `hsPkgs` but compiled with ghcjs |
169+
| `projectVariants` | Attrset | Attribute set of variant for the project, mapped from `flake.variants` config values |
169170
| `appendModule` | Function | Re-eval the project with an extra module (or module list). |
170171
| `extend` and `appendOverlays` | Function | Modify a project, or add attributes, through overlays: `p.extend(final: prev: { })`. The overlays are carried-over `projectCross` and `appendModule` invocations. |
171172

overlays/haskell.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,10 @@ final: prev: {
623623
.extend project.__overlay__
624624
) final.pkgsCross) // { recurseForDerivations = false; };
625625

626+
# attribute set of variant (with an extra module applied) for the project,
627+
# mapped from `flake.variants` config values.
628+
projectVariants = final.lib.mapAttrs (_: project.appendModule) project.args.flake.variants;
629+
626630
# re-eval this project with an extra module (or module list).
627631
appendModule = extraProjectModule: (rawProject.projectFunction final.haskell-nix
628632
((if builtins.isList rawProject.projectModule
@@ -762,8 +766,8 @@ final: prev: {
762766
forAllVariants =
763767
forAllCrossCompilers "default" project
764768
++ final.lib.concatLists (final.lib.mapAttrsToList
765-
(name: projectModule: forAllCrossCompilers name (project.appendModule projectModule))
766-
project.args.flake.variants);
769+
(name: projectVariant: forAllCrossCompilers name projectVariant)
770+
project.projectVariants);
767771
in haskellLib.combineFlakes ":" (builtins.foldl' (a: b: a // b) {} forAllVariants);
768772
flake = args: (project.appendModule { flake = args; }).flake';
769773

0 commit comments

Comments
 (0)