on iko/ghcjs-patch-master help sign in
Add appendModule function to projects. (#1240)

Allow re-eval of the project with an extra module (or module list).

commit749a7dc068d168b806d6f5d6e113c18a8b47475b authorJean-Baptiste Giraudeau <jean-baptiste.giraudeau@iohk.io> dateSat 18 Sep 2021, 04:43 (5 years ago) parentc386fd6
2 files changed+12−2
docs/reference/library.md+3−2 overlays/haskell.nix+9
docs/reference/library.md+3−2
@@ -144,7 +144,7 @@ Then feeding its result into [mkStackPkgSet](#mkstackpkgset) passing also
144144| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
145145| `stack-nix` | | `projectNix` attribute of [`callStackToNix`](#callstacktonix) return value |
146146| `shellFor` | Function | [`shellFor`](#shellfor) |
147−| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
147+| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
148148| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
149149
150150
@@ -163,9 +163,10 @@ Then feeding its result into [mkCabalProjectPkgSet](#mkcabalprojectpkgset) passi
163163| `plan-nix` | | `projectNix` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
164164| `index-state` | | `index-state` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
165165| `shellFor` | Function | [`shellFor`](#shellfor) |
166−| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
166+| `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+| `appendModule` | Function | Re-eval the project with an extra module (or module list). |
169170
170171## project, cabalProject and stackProject
171172
overlays/haskell.nix+9
@@ -577,6 +577,15 @@ final: prev: {
577577 rawProject.projectFunction pkgs.haskell-nix rawProject.projectModule
578578 ) final.pkgsCross) // { recurseForDerivations = false; };
579579
580+ # re-eval this project with an extra module (or module list).
581+ appendModule = extraProjectModule: rawProject.projectFunction final.haskell-nix
582+ ((if builtins.isList rawProject.projectModule
583+ then rawProject.projectModule
584+ else [rawProject.projectModule])
585+ ++ (if builtins.isList extraProjectModule
586+ then extraProjectModule
587+ else [extraProjectModule]));
588+
580589 # Add support for passing in `crossPlatforms` argument.
581590 # crossPlatforms is an easy way to include the inputs for a basic
582591 # cross platform shell in a native shell.