on iko/ghcjs-patch-master help sign in
Add `stack-nix` to `stackProject` (#293)

Like `plan-nix` for `cabalProject` this gives us a way to inspect the nix files generated by `stack-to-nix`. It may also adds `stackProject'` that like `cabalProject'` allows us to get `stack-nix` independently of hsPkgs (to avoid unwanted evaluation). This can be useful for caching and preventing GC of evaluation time dependencies of the project.

commit63fc8bec4cf18a5b15e2451062af88a49e4fd22e authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateTue 5 Nov 2019, 19:36 (7 years ago) parent8406e45
1 file changed+13−5
overlays/haskell.nix+13−5
overlays/haskell.nix+13−5
@@ -310,7 +310,7 @@ self: super: {
310310 modules = (args.modules or [])
311311 ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
312312 };
313− in {inherit (pkg-set.config) hsPkgs; plan-nix = plan.nix; };
313+ in { inherit (pkg-set.config) hsPkgs; plan-nix = plan.nix; };
314314
315315 cabalProject = args: let p = cabalProject' args;
316316 in p.hsPkgs // {
@@ -320,17 +320,25 @@ self: super: {
320320 shells.ghc = p.hsPkgs.shellFor {};
321321 };
322322
323− stackProject =
323+ stackProject' =
324324 { ... }@args:
325− let stack-pkgs = (importAndFilterProject (callStackToNix args)).pkgs;
325+ let stack = importAndFilterProject (callStackToNix args);
326326 in let pkg-set = mkStackPkgSet
327− { inherit stack-pkgs;
327+ { stack-pkgs = stack.pkgs;
328328 pkg-def-extras = (args.pkg-def-extras or []);
329329 modules = (args.modules or [])
330330 ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; }
331331 ++ self.lib.optional (args ? cache) (mkCacheModule args.cache);
332332 };
333− in pkg-set.config.hsPkgs;
333+ in { inherit (pkg-set.config) hsPkgs; stack-nix = stack.nix; };
334+
335+ stackProject = args: let p = stackProject' args;
336+ in p.hsPkgs // {
337+ inherit (p) stack-nix;
338+ # Provide `nix-shell -A shells.ghc` for users migrating from the reflex-platform.
339+ # But we should encourage use of `nix-shell -A shellFor`
340+ shells.ghc = p.hsPkgs.shellFor {};
341+ };
334342
335343 # The functions that return a plan-nix often have a lot of dependencies
336344 # that could be GCed and also will not make it into hydra cache.