rename: incremental -> checkpointed builds
This commit is contained in:
parent
ddfddf4b71
commit
6db9612204
9 changed files with 37 additions and 37 deletions
|
@ -7,5 +7,5 @@ special/fhs-environments.section.md
|
||||||
special/makesetuphook.section.md
|
special/makesetuphook.section.md
|
||||||
special/mkshell.section.md
|
special/mkshell.section.md
|
||||||
special/vm-tools.section.md
|
special/vm-tools.section.md
|
||||||
special/incremental-build.section.md
|
special/checkpoint-build.section.md
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
# pkgs.buildIncremental.* {#sec-incremental-build}
|
# pkgs.checkpointBuildTools.* {#sec-checkpoint-build}
|
||||||
|
|
||||||
`pkgs.buildIncremental` provides a way to build derivations incrementally. It consists of two functions to make incremental builds using nix possible.
|
`pkgs.checkpointBuildTools` provides a way to build derivations incrementally. It consists of two functions to make checkpoint builds using nix possible.
|
||||||
|
|
||||||
For hermeticity, Nix derivations do not allow any state to carry over between builds, making a transparent incremental build within a derivation impossible.
|
For hermeticity, Nix derivations do not allow any state to carry over between builds, making a transparent incremental build within a derivation impossible.
|
||||||
|
|
||||||
However, we can tell Nix explicitly what the previous build state was, by representing that previous state as a derivation output. This allows the passed build state to be used for an incremental build.
|
However, we can tell Nix explicitly what the previous build state was, by representing that previous state as a derivation output. This allows the passed build state to be used for an incremental build.
|
||||||
|
|
||||||
To build a derivation incrementally, the following steps needs to be fullfilled:
|
To build a derivation based on build checkpoints, the following steps needs to be fullfilled:
|
||||||
* - run prepareIncrementalBuild on the desired derivation
|
* - run prepareCheckpointBuild on the desired derivation
|
||||||
* e.G `incrementalBuildArtifacts = (pkgs.buildIncremental.prepareIncrementalBuild pkgs.virtualbox);`
|
* e.G `checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox);`
|
||||||
* - change something you want in the sources of the package( e.G using source override)
|
* - change something you want in the sources of the package( e.G using source override)
|
||||||
* changedVBox = pkgs.virtuabox.overrideAttrs (old: {
|
* changedVBox = pkgs.virtuabox.overrideAttrs (old: {
|
||||||
* src = path/to/vbox/sources;
|
* src = path/to/vbox/sources;
|
||||||
* }
|
* }
|
||||||
* - use `mkIncrementalBuild changedVBox buildOutput`
|
* - use `mkCheckpointedBuild changedVBox buildOutput`
|
||||||
* enjoy shorter build times
|
* enjoy shorter build times
|
||||||
|
|
||||||
As Nix has no builtin support for the detection of the previous built derivation, a base version needs to be declared.
|
As Nix has no builtin support for the detection of the previous built derivation, a base version needs to be declared.
|
||||||
To create the outputs later used as base version for incremental builds, the function `pkgs.buildIncremental.prepareIncrementalBuild` is used.
|
To create the outputs later used as base version for checkpoint builds, the function `pkgs.checkpointBuildTools.prepareCheckpointBuild` is used.
|
||||||
The function takes the original derivation as an argument and transforms the output to a base version for an incremental build.
|
The function takes the original derivation as an argument and transforms the output to a base version for an checkpoint build build.
|
||||||
While doing so, the original output is not created and the installation phase is overwritten to produce the incremental build artifacts.
|
While doing so, the original output is not created and the installation phase is overwritten to produce the checkpoint artifacts.
|
||||||
|
|
||||||
When the built artifacts of the base version of the derivation are created, the code can be modified and changes are built using the `pkgs.buildIncremental.mkIncrementalBuild` function.
|
When the built artifacts of the base version of the derivation are created, the code can be modified and changes are built using the `pkgs.checkpointBuildTools.mkCheckpointedBuild` function.
|
||||||
The `pkgs.buildIncremental.mkIncrementalBuild` function detects the changes in the code and places the output of the base version derivation within the build folder.
|
The `pkgs.checkpointBuildTools.mkCheckpointedBuild` function detects the changes in the code and places the output of the base version derivation within the build folder.
|
||||||
Then, the build tool is able to detect the changes and makes the decision of which parts of the derivation needs to be recompiled and produces the output, as expected in the derivation, without incremental build support.
|
Then, the build tool is able to detect the changes and makes the decision of which parts of the derivation needs to be recompiled and produces the output, as expected in the derivation, without checkpoint build support.
|
||||||
|
|
||||||
|
|
|
@ -2,24 +2,24 @@
|
||||||
rec {
|
rec {
|
||||||
/* Prepare a derivation for local builds.
|
/* Prepare a derivation for local builds.
|
||||||
*
|
*
|
||||||
* This function prepares incremental builds by provinding,
|
* This function prepares checkpoint builds by provinding,
|
||||||
* containing the build output and the sources for cross checking.
|
* containing the build output and the sources for cross checking.
|
||||||
* The build output can be used later to allow incremental builds
|
* The build output can be used later to allow checkpoint builds
|
||||||
* by passing the derivation output to the `mkIncrementalBuild` function.
|
* by passing the derivation output to the `mkCheckpointBuild` function.
|
||||||
*
|
*
|
||||||
* To build a project incrementaly follow these steps:
|
* To build a project with checkpoints follow these steps:
|
||||||
* - run prepareIncrementalBuild on the desired derivation
|
* - run prepareIncrementalBuild on the desired derivation
|
||||||
* e.G `incrementalBuildArtifacts = (pkgs.buildIncremental.prepareIncrementalBuild pkgs.virtualbox);`
|
* e.G `incrementalBuildArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox);`
|
||||||
* - change something you want in the sources of the package( e.G using source override)
|
* - change something you want in the sources of the package( e.G using source override)
|
||||||
* changedVBox = pkgs.virtuabox.overrideAttrs (old: {
|
* changedVBox = pkgs.virtuabox.overrideAttrs (old: {
|
||||||
* src = path/to/vbox/sources;
|
* src = path/to/vbox/sources;
|
||||||
* }
|
* }
|
||||||
* - use `mkIncrementalBuild changedVBox buildOutput`
|
* - use `mkCheckpointedBuild changedVBox buildOutput`
|
||||||
* - enjoy shorter build times
|
* - enjoy shorter build times
|
||||||
*/
|
*/
|
||||||
prepareIncrementalBuild = drv: drv.overrideAttrs (old: {
|
prepareCheckpointBuild = drv: drv.overrideAttrs (old: {
|
||||||
outputs = [ "out" ];
|
outputs = [ "out" ];
|
||||||
name = drv.name + "-incrementalBuildArtifacts";
|
name = drv.name + "-checkpointArtifacts";
|
||||||
# To determine differences between the state of the build directory
|
# To determine differences between the state of the build directory
|
||||||
# from an earlier build and a later one we store the state of the build
|
# from an earlier build and a later one we store the state of the build
|
||||||
# directory before build, but after patch phases.
|
# directory before build, but after patch phases.
|
||||||
|
@ -41,16 +41,16 @@ rec {
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Build a derivation incrementally based on the output generated by
|
/* Build a derivation based on the checkpoint output generated by
|
||||||
* the `prepareIncrementalBuild function.
|
* the `prepareCheckpointBuild function.
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* let
|
* let
|
||||||
* incrementalBuildArtifacts = prepareIncrementalBuild drv
|
* checkpointArtifacts = prepareCheckpointBuild drv
|
||||||
* in mkIncrementalBuild drv incrementalBuildArtifacts
|
* in mkCheckpointedBuild drv checkpointArtifacts
|
||||||
*/
|
*/
|
||||||
mkIncrementalBuild = drv: previousBuildArtifacts: drv.overrideAttrs (old: {
|
mkCheckpointedBuild = drv: previousBuildArtifacts: drv.overrideAttrs (old: {
|
||||||
# The actual incremental build phase.
|
# The actual checkpoint build phase.
|
||||||
# We compare the changed sources from a previous build with the current and create a patch
|
# We compare the changed sources from a previous build with the current and create a patch
|
||||||
# Afterwards we clean the build directory to copy the previous output files (Including the sources)
|
# Afterwards we clean the build directory to copy the previous output files (Including the sources)
|
||||||
# The source difference patch is applied to get the latest changes again to allow short build times.
|
# The source difference patch is applied to get the latest changes again to allow short build times.
|
|
@ -1,6 +1,6 @@
|
||||||
{ hello, incrementalBuildTools, runCommandNoCC, texinfo, stdenv, rsync }:
|
{ hello, checkpointBuildTools, runCommandNoCC, texinfo, stdenv, rsync }:
|
||||||
let
|
let
|
||||||
baseHelloArtifacts = incrementalBuildTools.prepareIncrementalBuild hello;
|
baseHelloArtifacts = checkpointBuildTools.prepareCheckpointBuild hello;
|
||||||
patchedHello = hello.overrideAttrs (old: {
|
patchedHello = hello.overrideAttrs (old: {
|
||||||
buildInputs = [ texinfo ];
|
buildInputs = [ texinfo ];
|
||||||
src = runCommandNoCC "patch-hello-src" { } ''
|
src = runCommandNoCC "patch-hello-src" { } ''
|
||||||
|
@ -10,9 +10,9 @@ let
|
||||||
patch -p1 < ${./hello.patch}
|
patch -p1 < ${./hello.patch}
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
incrementalBuiltHello = incrementalBuildTools.mkIncrementalBuild patchedHello baseHelloArtifacts;
|
checkpointBuiltHello = checkpointBuildTools.mkCheckpointedBuild patchedHello baseHelloArtifacts;
|
||||||
|
|
||||||
incrementalBuiltHelloWithCheck = incrementalBuiltHello.overrideAttrs (old: {
|
checkpointBuiltHelloWithCheck = checkpointBuiltHello.overrideAttrs (old: {
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
checkPhase = ''
|
checkPhase = ''
|
||||||
echo "checking if unchanged source file is not recompiled"
|
echo "checking if unchanged source file is not recompiled"
|
||||||
|
@ -20,7 +20,7 @@ let
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
baseHelloRemoveFileArtifacts = incrementalBuildTools.prepareIncrementalBuild (hello.overrideAttrs (old: {
|
baseHelloRemoveFileArtifacts = checkpointBuildTools.prepareCheckpointBuild (hello.overrideAttrs (old: {
|
||||||
patches = [ ./hello-additionalFile.patch ];
|
patches = [ ./hello-additionalFile.patch ];
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ let
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
incrementalBuiltHelloWithRemovedFile = incrementalBuildTools.mkIncrementalBuild patchedHelloRemoveFile baseHelloRemoveFileArtifacts;
|
checkpointBuiltHelloWithRemovedFile = checkpointBuildTools.mkCheckpointedBuild patchedHelloRemoveFile baseHelloRemoveFileArtifacts;
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "patched-hello-returns-correct-output";
|
name = "patched-hello-returns-correct-output";
|
||||||
|
@ -49,9 +49,9 @@ stdenv.mkDerivation {
|
||||||
touch $out
|
touch $out
|
||||||
|
|
||||||
echo "testing output of hello binary"
|
echo "testing output of hello binary"
|
||||||
[ "$(${incrementalBuiltHelloWithCheck}/bin/hello)" = "Hello, incremental world!" ]
|
[ "$(${checkpointBuiltHelloWithCheck}/bin/hello)" = "Hello, incremental world!" ]
|
||||||
echo "testing output of hello with removed file"
|
echo "testing output of hello with removed file"
|
||||||
[ "$(${incrementalBuiltHelloWithRemovedFile}/bin/hello)" = "Hello, incremental world!" ]
|
[ "$(${checkpointBuiltHelloWithRemovedFile}/bin/hello)" = "Hello, incremental world!" ]
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ with pkgs;
|
||||||
|
|
||||||
install-shell-files = callPackage ./install-shell-files {};
|
install-shell-files = callPackage ./install-shell-files {};
|
||||||
|
|
||||||
incremental-build = callPackage ./incrementalBuild {};
|
checkpoint-build = callPackage ./checkpointBuild {};
|
||||||
|
|
||||||
kernel-config = callPackage ./kernel.nix {};
|
kernel-config = callPackage ./kernel.nix {};
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,7 @@ with pkgs;
|
||||||
|
|
||||||
camunda-modeler = callPackage ../applications/misc/camunda-modeler { };
|
camunda-modeler = callPackage ../applications/misc/camunda-modeler { };
|
||||||
|
|
||||||
incrementalBuildTools = callPackage ../build-support/build-incremental.nix {};
|
checkpointBuildTools = callPackage ../build-support/checkpoint-build.nix {};
|
||||||
|
|
||||||
caroline = callPackage ../development/libraries/caroline { };
|
caroline = callPackage ../development/libraries/caroline { };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue