biome: 1.9.2 -> 1.9.3
[NixPkgs.git] / pkgs / test / checkpointBuild / default.nix
blob0843dcd3d6eba405b859289fb8cd805a7613bd27
1 { hello, checkpointBuildTools, runCommand, texinfo, stdenv, rsync }:
2 let
3   baseHelloArtifacts = checkpointBuildTools.prepareCheckpointBuild hello;
4   patchedHello = hello.overrideAttrs (old: {
5     buildInputs = [ texinfo ];
6     src = runCommand "patch-hello-src" { } ''
7       mkdir -p $out
8       cd $out
9       tar xf ${hello.src} --strip-components=1
10       patch -p1 < ${./hello.patch}
11     '';
12   });
13   checkpointBuiltHello = checkpointBuildTools.mkCheckpointBuild patchedHello baseHelloArtifacts;
15   checkpointBuiltHelloWithCheck = checkpointBuiltHello.overrideAttrs (old: {
16     doCheck = true;
17     checkPhase = ''
18       echo "checking if unchanged source file is not recompiled"
19         [ "$(stat --format="%Y" lib/exitfail.o)" = "$(stat --format="%Y" ${baseHelloArtifacts}/outputs/lib/exitfail.o)" ]
20     '';
21   });
23   baseHelloRemoveFileArtifacts = checkpointBuildTools.prepareCheckpointBuild (hello.overrideAttrs (old: {
24     patches = [ ./hello-additionalFile.patch ];
25   }));
27   preparedHelloRemoveFileSrc = runCommand "patch-hello-src" { } ''
28     mkdir -p $out
29     cd $out
30     tar xf ${hello.src} --strip-components=1
31     patch -p1 < ${./hello-additionalFile.patch}
32   '';
34   patchedHelloRemoveFile = hello.overrideAttrs (old: {
35     buildInputs = [ texinfo ];
36     src = runCommand "patch-hello-src" { } ''
37       mkdir -p $out
38       cd $out
39       ${rsync}/bin/rsync -cutU --chown=$USER:$USER --chmod=+w -r ${preparedHelloRemoveFileSrc}/* .
40       patch -p1 < ${./hello-removeFile.patch}
41     '';
42   });
44   checkpointBuiltHelloWithRemovedFile = checkpointBuildTools.mkCheckpointBuild patchedHelloRemoveFile baseHelloRemoveFileArtifacts;
46 stdenv.mkDerivation {
47   name = "patched-hello-returns-correct-output";
48   buildCommand = ''
49     touch $out
51     echo "testing output of hello binary"
52     [ "$(${checkpointBuiltHelloWithCheck}/bin/hello)" = "Hello, incremental world!" ]
53     echo "testing output of hello with removed file"
54     [ "$(${checkpointBuiltHelloWithRemovedFile}/bin/hello)" = "Hello, incremental world!" ]
55   '';