···
prepareIncrementalBuild = drv: drv.overrideAttrs (old: {
name = drv.name + "-incrementalBuildArtifacts";
23
+
# To determine differences between the state of the build directory
24
+
# from an earlier build and a later one we store the state of the build
25
+
# directory before build, but after patch phases.
26
+
# This way, the same derivation can be used multiple times and only changes are detected.
27
+
# Additionally Removed files are handled correctly in later builds.
preBuild = (old.preBuild or "") + ''
33
+
# After the build the build directory is copied again
34
+
# to get the output files.
35
+
# We copy the complete build folder, to take care for
36
+
# Build tools, building in the source directory, instead of
37
+
# having a build root directory, e.G the Linux kernel.
···
* in mkIncrementalBuild drv incrementalBuildArtifacts
mkIncrementalBuild = drv: previousBuildArtifacts: drv.overrideAttrs (old: {
53
+
# The actual incremental build phase.
54
+
# We compare the changed sources from a previous build with the current and create a patch
55
+
# Afterwards we clean the build directory to copy the previous output files (Including the sources)
56
+
# The source difference patch is applied to get the latest changes again to allow short build times.
preBuild = (old.preBuild or "") + ''
diff -ur ${previousBuildArtifacts}/sources ./ > sourceDifference.patch