mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
Checkpointedbuilds: add derivation override functions
One can use this functions to allow incremental builds of derivations
This commit is contained in:
parent
2453c821f0
commit
3f4e3a862f
37
pkgs/build-support/build-incremental.nix
Normal file
37
pkgs/build-support/build-incremental.nix
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{ pkgs }:
|
||||||
|
rec {
|
||||||
|
/* Prepare a derivation for local builds.
|
||||||
|
*
|
||||||
|
* This function adds an additional outout for a derivation,
|
||||||
|
* containing the build output.
|
||||||
|
* The build output can be used later to allow incremental builds
|
||||||
|
* by passing the `buildOut` output to the `mkIncrementalBuild` function.
|
||||||
|
*/
|
||||||
|
prepareIncrementalBuild = drv: drv.overrideAttrs (old: {
|
||||||
|
outputs = (old.outputs or [ "out" ]) ++ [ "buildOut" ];
|
||||||
|
installPhase = pkgs.lib.optionalString (!(builtins.hasAttr "outputs" old)) ''
|
||||||
|
mkdir -p $out
|
||||||
|
'' + (old.installPhase or "") + ''
|
||||||
|
mkdir -p $buildOut
|
||||||
|
cp -r ./* $buildOut/
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Build a derivation incrementally based on the output generated by
|
||||||
|
* the `prepareIncrementalBuild function.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* let
|
||||||
|
* buildOutput = (prepareIncrementalBuild drv).buildOut
|
||||||
|
* in mkIncrementalBuild drv buildOutput
|
||||||
|
*/
|
||||||
|
mkIncrementalBuild = drv: previousBuildArtifacts: drv.overrideAttrs (old: {
|
||||||
|
prePatch = ''
|
||||||
|
for file in $(diff -r ./ ${previousBuildArtifacts} --brief | grep "Files" |sed 's/^Only in \([^:]*\): /\1\//' | sed 's/^Files \(.*\) and .* differ/\1/')
|
||||||
|
do
|
||||||
|
touch $file
|
||||||
|
done
|
||||||
|
${pkgs.rsync}/bin/rsync -cutU --chown=$USER:$USER --chmod=+w -r ${previousBuildArtifacts}/* .
|
||||||
|
'' + (old.prePatch or "");
|
||||||
|
});
|
||||||
|
}
|
@ -429,6 +429,8 @@ with pkgs;
|
|||||||
|
|
||||||
camunda-modeler = callPackage ../applications/misc/camunda-modeler { };
|
camunda-modeler = callPackage ../applications/misc/camunda-modeler { };
|
||||||
|
|
||||||
|
inncrementalBuildTools = callPackage ../build-support/build-incremental.nix {};
|
||||||
|
|
||||||
caroline = callPackage ../development/libraries/caroline { };
|
caroline = callPackage ../development/libraries/caroline { };
|
||||||
|
|
||||||
cartridges = callPackage ../applications/misc/cartridges { };
|
cartridges = callPackage ../applications/misc/cartridges { };
|
||||||
|
Loading…
Reference in New Issue
Block a user