1# pkgs.checkpointBuildTools {#sec-checkpoint-build} 2 3`pkgs.checkpointBuildTools` provides a way to build derivations incrementally. It consists of two functions to make checkpoint builds using Nix possible. 4 5For hermeticity, Nix derivations do not allow any state to be carried over between builds, making a transparent incremental build within a derivation impossible. 6 7However, 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. 8 9To change a normal derivation to a checkpoint based build, these steps must be taken: 10 ```nix 11 { 12 checkpointArtifacts = (pkgs.checkpointBuildTools.prepareCheckpointBuild pkgs.virtualbox); 13 } 14 ``` 15 ```nix 16 { 17 changedVBox = pkgs.virtualbox.overrideAttrs (old: { 18 src = path/to/vbox/sources; 19 }); 20 } 21 ``` 22 - use `mkCheckpointBuild changedVBox checkpointArtifacts` 23 - enjoy shorter build times 24 25## Example {#sec-checkpoint-build-example} 26```nix 27{ 28 pkgs ? import <nixpkgs> { }, 29}: 30let 31 inherit (pkgs.checkpointBuildTools) prepareCheckpointBuild mkCheckpointBuild; 32 helloCheckpoint = prepareCheckpointBuild pkgs.hello; 33 changedHello = pkgs.hello.overrideAttrs (_: { 34 doCheck = false; 35 postPatch = '' 36 sed -i 's/Hello, world!/Hello, Nix!/g' src/hello.c 37 ''; 38 }); 39in 40mkCheckpointBuild changedHello helloCheckpoint 41```