on iko/ghcjs-patch-master help sign in
Add haskellNixRoots and withInputs to help caching (#271)
1a28ea9Hamish Mackenzie
@@ -27,7 +27,7 @@ let
27 haskell = pkgs.haskell-nix;
27 haskell = pkgs.haskell-nix;
28
28
29in {
29in {
30− inherit (haskell) nix-tools source-pins;
30+ inherit (haskell) haskellNixRoots;
31 tests = import ./test/default.nix { inherit nixpkgs nixpkgsArgs; };
31 tests = import ./test/default.nix { inherit nixpkgs nixpkgsArgs; };
32
32
33 # Scripts for keeping Hackage and Stackage up to date, and CI tasks.
33 # Scripts for keeping Hackage and Stackage up to date, and CI tasks.
overlays/ghc-packages.nix+4−2
@@ -81,10 +81,12 @@ in rec {
81 '';
81 '';
82 }) self.buildPackages.haskell.compiler;
82 }) self.buildPackages.haskell.compiler;
83
83
84− ghc-extra-packages = builtins.mapAttrs (name: proj: self.haskell-nix.cabalProject {
84+ ghc-extra-projects = builtins.mapAttrs (name: proj: self.haskell-nix.cabalProject' {
85 name = "ghc-extra-packages";
85 name = "ghc-extra-packages";
86 src = proj;
86 src = proj;
87 ghc = self.buildPackages.haskell.compiler.${name};
87 ghc = self.buildPackages.haskell.compiler.${name};
88 })
88 })
89 ghc-extra-pkgs-cabal-projects;
89 ghc-extra-pkgs-cabal-projects;
90+
91+ ghc-extra-packages = builtins.mapAttrs (_: proj: proj.hsPkgs) ghc-extra-projects;
90−}
92+}
overlays/haskell.nix+30
@@ -297,6 +297,9 @@ self: super: {
297 '';
297 '';
298 in cabalProject (builtins.removeAttrs args [ "version" ] // { inherit src; });
298 in cabalProject (builtins.removeAttrs args [ "version" ] // { inherit src; });
299
299
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.
300 cabalProject' =
303 cabalProject' =
301 { name ? null
304 { name ? null
302 , ... }@args:
305 , ... }@args:
@@ -328,5 +331,32 @@ self: super: {
328 ++ self.lib.optional (args ? cache) (mkCacheModule args.cache);
331 ++ self.lib.optional (args ? cache) (mkCacheModule args.cache);
329 };
332 };
330 in pkg-set.config.hsPkgs;
333 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+ });
331 };
361 };
332}
362}