about summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorRebecca Turner <rbt@sent.as>2023-04-20 12:59:32 -0700
committerRebecca Turner <rbt@sent.as>2023-05-25 14:36:18 -0700
commitb278ca21951756049272c752bcf2601318633205 (patch)
tree93e19a18e647c576ba54eda756796ec2b5eed744 /pkgs/test
parentc072d7867d215c0d5db843ef90fb2393a67384f5 (diff)
downloadnixlib-b278ca21951756049272c752bcf2601318633205.tar
nixlib-b278ca21951756049272c752bcf2601318633205.tar.gz
nixlib-b278ca21951756049272c752bcf2601318633205.tar.bz2
nixlib-b278ca21951756049272c752bcf2601318633205.tar.lz
nixlib-b278ca21951756049272c752bcf2601318633205.tar.xz
nixlib-b278ca21951756049272c752bcf2601318633205.tar.zst
nixlib-b278ca21951756049272c752bcf2601318633205.zip
tests.haskell.incremental: init
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/haskell/default.nix1
-rw-r--r--pkgs/test/haskell/incremental/default.nix35
2 files changed, 36 insertions, 0 deletions
diff --git a/pkgs/test/haskell/default.nix b/pkgs/test/haskell/default.nix
index 337d2811c655..86764380ecc3 100644
--- a/pkgs/test/haskell/default.nix
+++ b/pkgs/test/haskell/default.nix
@@ -6,4 +6,5 @@ lib.recurseIntoAttrs {
   documentationTarball = callPackage ./documentationTarball { };
   setBuildTarget = callPackage ./setBuildTarget { };
   writers = callPackage ./writers { };
+  incremental = callPackage ./incremental { };
 }
diff --git a/pkgs/test/haskell/incremental/default.nix b/pkgs/test/haskell/incremental/default.nix
new file mode 100644
index 000000000000..b94a85277db3
--- /dev/null
+++ b/pkgs/test/haskell/incremental/default.nix
@@ -0,0 +1,35 @@
+# Demonstration of incremental builds for Haskell. Useful for speeding up CI.
+#
+# See: https://www.haskellforall.com/2022/12/nixpkgs-support-for-incremental-haskell.html
+# See: https://felixspringer.xyz/homepage/blog/incrementalHaskellBuildsWithNix
+
+{ haskell, lib }:
+
+let
+  inherit (haskell.lib.compose) overrideCabal;
+
+  # Incremental builds work with GHC >=9.4.
+  turtle = haskell.packages.ghc944.turtle;
+
+  # This will do a full build of `turtle`, while writing the intermediate build products
+  # (compiled modules, etc.) to the `intermediates` output.
+  turtle-full-build-with-incremental-output = overrideCabal (drv: {
+    doInstallIntermediates = true;
+    enableSeparateIntermediatesOutput = true;
+  }) turtle;
+
+  # This will do an incremental build of `turtle` by copying the previously
+  # compiled modules and intermediate build products into the source tree
+  # before running the build.
+  #
+  # GHC will then naturally pick up and reuse these products, making this build
+  # complete much more quickly than the previous one.
+  turtle-incremental-build = overrideCabal (drv: {
+    previousIntermediates = turtle-full-build-with-incremental-output.intermediates;
+  }) turtle;
+in
+  turtle-incremental-build.overrideAttrs (old: {
+    meta = {
+      maintainers = lib.teams.mercury.members;
+    };
+  })