@@ -297,6 +297,9 @@ self: super: {
297297 '';
298298 in cabalProject (builtins.removeAttrs args [ "version" ] // { inherit src; });
299299
300+ # This function is like `cabalProject` but it makes the plan-nix available
301+ # separately from the hsPkgs. The advantage is that the you can get the
302+ # plan-nix without building the project.
300303 cabalProject' =
301304 { name ? null
302305 , ... }@args:
@@ -328,5 +331,32 @@ self: super: {
328331 ++ self.lib.optional (args ? cache) (mkCacheModule args.cache);
329332 };
330333 in pkg-set.config.hsPkgs;
334+
335+ # The functions that return a plan-nix often have a lot of dependencies
336+ # that could be GCed and also will not make it into hydra cache.
337+ # Use this `withInputs` function to make sure your tests include
338+ # the dependencies needed explicitly. For example, if you have:
339+ # project = cabalProject' {...};
340+ # In your tests module add something that is effectively
341+ # testProjectPlan = withInputs project.plan-nix;
342+ withInputs = derivation: builtins.mapAttrs (_: self.recurseIntoAttrs) {
343+ inherit derivation;
344+ inputs = builtins.listToAttrs (
345+ builtins.concatMap (i: if i == null then [] else [
346+ { name = builtins.replaceStrings ["."] ["_"] i.name; value = i; }
347+ ]) derivation.nativeBuildInputs);
348+ };
349+
350+ # Add this to your tests to make all the dependencies of haskell.nix
351+ # are tested and cached.
352+ haskellNixRoots = self.recurseIntoAttrs (builtins.mapAttrs (_: self.recurseIntoAttrs) {
353+ inherit (self.haskell-nix) nix-tools source-pins;
354+ bootstap-nix-tools = self.bootstrap.haskell.packages.nix-tools;
355+ alex-plan-nix = withInputs self.bootstrap.haskell.packages.alex-project.plan-nix;
356+ happy-plan-nix = withInputs self.bootstrap.haskell.packages.happy-project.plan-nix;
357+ hscolour-plan-nix = withInputs self.bootstrap.haskell.packages.hscolour-project.plan-nix;
358+ ghc-extra-projects = builtins.mapAttrs (_: proj: self.recurseIntoAttrs (withInputs proj.plan-nix))
359+ (self.lib.filterAttrs (n: _: n != "ghc844" && n != "ghc861" && n != "ghc862") self.ghc-extra-projects);
360+ });
331361 };
332362}