From 6db96122047fe7bdc1d58e201c9d161c0c479aba Mon Sep 17 00:00:00 2001 From: Martin Messer Date: Tue, 20 Dec 2022 13:53:03 +0100 Subject: [PATCH] rename: incremental -> checkpointed builds --- doc/build-helpers/special.md | 2 +- ...section.md => checkpoint-build.section.md} | 24 ++++++++-------- ...d-incremental.nix => checkpoint-build.nix} | 28 +++++++++---------- .../default.nix | 16 +++++------ .../hello-additionalFile.patch | 0 .../hello-removeFile.patch | 0 .../hello.patch | 0 pkgs/test/default.nix | 2 +- pkgs/top-level/all-packages.nix | 2 +- 9 files changed, 37 insertions(+), 37 deletions(-) rename doc/build-helpers/special/{incremental-build.section.md => checkpoint-build.section.md} (52%) rename pkgs/build-support/{build-incremental.nix => checkpoint-build.nix} (69%) rename pkgs/test/{incrementalBuild => checkpointBuild}/default.nix (63%) rename pkgs/test/{incrementalBuild => checkpointBuild}/hello-additionalFile.patch (100%) rename pkgs/test/{incrementalBuild => checkpointBuild}/hello-removeFile.patch (100%) rename pkgs/test/{incrementalBuild => checkpointBuild}/hello.patch (100%) diff --git a/doc/build-helpers/special.md b/doc/build-helpers/special.md index baf40a261e81..265c2da92bf1 100644 --- a/doc/build-helpers/special.md +++ b/doc/build-helpers/special.md @@ -7,5 +7,5 @@ special/fhs-environments.section.md special/makesetuphook.section.md special/mkshell.section.md special/vm-tools.section.md -special/incremental-build.section.md +special/checkpoint-build.section.md ``` diff --git a/doc/build-helpers/special/incremental-build.section.md b/doc/build-helpers/special/checkpoint-build.section.md similarity index 52% rename from doc/build-helpers/special/incremental-build.section.md rename to doc/build-helpers/special/checkpoint-build.section.md index f8e81ddeffc5..ae26d9db1a2e 100644 --- a/doc/build-helpers/special/incremental-build.section.md +++ b/doc/build-helpers/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. 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: - * - run prepareIncrementalBuild on the desired derivation - * e.G `incrementalBuildArtifacts = (pkgs.buildIncremental.prepareIncrementalBuild pkgs.virtualbox);` +To build a derivation based on build checkpoints, the following steps needs to be fullfilled: + * - run prepareCheckpointBuild on the desired derivation + * e.G `checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox);` * - change something you want in the sources of the package( e.G using source override) * changedVBox = pkgs.virtuabox.overrideAttrs (old: { * src = path/to/vbox/sources; * } - * - use `mkIncrementalBuild changedVBox buildOutput` + * - use `mkCheckpointedBuild changedVBox buildOutput` * 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. -To create the outputs later used as base version for incremental builds, the function `pkgs.buildIncremental.prepareIncrementalBuild` is used. -The function takes the original derivation as an argument and transforms the output to a base version for an incremental build. -While doing so, the original output is not created and the installation phase is overwritten to produce the incremental build artifacts. +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 checkpoint build build. +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. -The `pkgs.buildIncremental.mkIncrementalBuild` 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. +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.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 checkpoint build support. diff --git a/pkgs/build-support/build-incremental.nix b/pkgs/build-support/checkpoint-build.nix similarity index 69% rename from pkgs/build-support/build-incremental.nix rename to pkgs/build-support/checkpoint-build.nix index e7bbf3871069..be25ca4d04b1 100644 --- a/pkgs/build-support/build-incremental.nix +++ b/pkgs/build-support/checkpoint-build.nix @@ -2,24 +2,24 @@ rec { /* 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. - * The build output can be used later to allow incremental builds - * by passing the derivation output to the `mkIncrementalBuild` function. + * The build output can be used later to allow checkpoint builds + * 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 - * 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) * changedVBox = pkgs.virtuabox.overrideAttrs (old: { * src = path/to/vbox/sources; * } - * - use `mkIncrementalBuild changedVBox buildOutput` + * - use `mkCheckpointedBuild changedVBox buildOutput` * - enjoy shorter build times */ - prepareIncrementalBuild = drv: drv.overrideAttrs (old: { + prepareCheckpointBuild = drv: drv.overrideAttrs (old: { outputs = [ "out" ]; - name = drv.name + "-incrementalBuildArtifacts"; + name = drv.name + "-checkpointArtifacts"; # 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 # directory before build, but after patch phases. @@ -41,16 +41,16 @@ rec { ''; }); - /* Build a derivation incrementally based on the output generated by - * the `prepareIncrementalBuild function. + /* Build a derivation based on the checkpoint output generated by + * the `prepareCheckpointBuild function. * * Usage: * let - * incrementalBuildArtifacts = prepareIncrementalBuild drv - * in mkIncrementalBuild drv incrementalBuildArtifacts + * checkpointArtifacts = prepareCheckpointBuild drv + * in mkCheckpointedBuild drv checkpointArtifacts */ - mkIncrementalBuild = drv: previousBuildArtifacts: drv.overrideAttrs (old: { - # The actual incremental build phase. + mkCheckpointedBuild = drv: previousBuildArtifacts: drv.overrideAttrs (old: { + # The actual checkpoint build phase. # 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) # The source difference patch is applied to get the latest changes again to allow short build times. diff --git a/pkgs/test/incrementalBuild/default.nix b/pkgs/test/checkpointBuild/default.nix similarity index 63% rename from pkgs/test/incrementalBuild/default.nix rename to pkgs/test/checkpointBuild/default.nix index b962befbfbac..4a59760230a6 100644 --- a/pkgs/test/incrementalBuild/default.nix +++ b/pkgs/test/checkpointBuild/default.nix @@ -1,6 +1,6 @@ -{ hello, incrementalBuildTools, runCommandNoCC, texinfo, stdenv, rsync }: +{ hello, checkpointBuildTools, runCommandNoCC, texinfo, stdenv, rsync }: let - baseHelloArtifacts = incrementalBuildTools.prepareIncrementalBuild hello; + baseHelloArtifacts = checkpointBuildTools.prepareCheckpointBuild hello; patchedHello = hello.overrideAttrs (old: { buildInputs = [ texinfo ]; src = runCommandNoCC "patch-hello-src" { } '' @@ -10,9 +10,9 @@ let patch -p1 < ${./hello.patch} ''; }); - incrementalBuiltHello = incrementalBuildTools.mkIncrementalBuild patchedHello baseHelloArtifacts; + checkpointBuiltHello = checkpointBuildTools.mkCheckpointedBuild patchedHello baseHelloArtifacts; - incrementalBuiltHelloWithCheck = incrementalBuiltHello.overrideAttrs (old: { + checkpointBuiltHelloWithCheck = checkpointBuiltHello.overrideAttrs (old: { doCheck = true; checkPhase = '' 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 ]; })); @@ -41,7 +41,7 @@ let ''; }); - incrementalBuiltHelloWithRemovedFile = incrementalBuildTools.mkIncrementalBuild patchedHelloRemoveFile baseHelloRemoveFileArtifacts; + checkpointBuiltHelloWithRemovedFile = checkpointBuildTools.mkCheckpointedBuild patchedHelloRemoveFile baseHelloRemoveFileArtifacts; in stdenv.mkDerivation { name = "patched-hello-returns-correct-output"; @@ -49,9 +49,9 @@ stdenv.mkDerivation { touch $out 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" - [ "$(${incrementalBuiltHelloWithRemovedFile}/bin/hello)" = "Hello, incremental world!" ] + [ "$(${checkpointBuiltHelloWithRemovedFile}/bin/hello)" = "Hello, incremental world!" ] ''; } diff --git a/pkgs/test/incrementalBuild/hello-additionalFile.patch b/pkgs/test/checkpointBuild/hello-additionalFile.patch similarity index 100% rename from pkgs/test/incrementalBuild/hello-additionalFile.patch rename to pkgs/test/checkpointBuild/hello-additionalFile.patch diff --git a/pkgs/test/incrementalBuild/hello-removeFile.patch b/pkgs/test/checkpointBuild/hello-removeFile.patch similarity index 100% rename from pkgs/test/incrementalBuild/hello-removeFile.patch rename to pkgs/test/checkpointBuild/hello-removeFile.patch diff --git a/pkgs/test/incrementalBuild/hello.patch b/pkgs/test/checkpointBuild/hello.patch similarity index 100% rename from pkgs/test/incrementalBuild/hello.patch rename to pkgs/test/checkpointBuild/hello.patch diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix index 8ca6c4faf56e..c23814747b41 100644 --- a/pkgs/test/default.nix +++ b/pkgs/test/default.nix @@ -113,7 +113,7 @@ with pkgs; install-shell-files = callPackage ./install-shell-files {}; - incremental-build = callPackage ./incrementalBuild {}; + checkpoint-build = callPackage ./checkpointBuild {}; kernel-config = callPackage ./kernel.nix {}; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4ad119789512..d2b9581e4b15 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -429,7 +429,7 @@ with pkgs; 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 { };