Skip to content

Instantly share code, notes, and snippets.

@rrbutani
Created January 24, 2023 06:02
Show Gist options
  • Save rrbutani/b991b50ecaa186ddc05e0176578cb916 to your computer and use it in GitHub Desktop.
Save rrbutani/b991b50ecaa186ddc05e0176578cb916 to your computer and use it in GitHub Desktop.
{ lib
, phases ? [
"Patch"
"Unpack"
"Configure"
"Build"
"Install"
"Check"
"InstallCheck"
]
}:
drv: let
timePhase = phaseName:
final: prev: let
pre = "pre${phaseName}";
post = "post${phaseName}";
in {
${pre} = ''
__${phaseName}Start=$(date +%s%3N)
'' + (prev.${pre} or "");
${post} = (prev.${post} or "") + ''
__${phaseName}End=$(date +%s%3N)
echo -e "\e[1;33m[TIMINGS]\e[0m $(( __${phaseName}End - __${phaseName}Start ))ms for ${phaseName} phase"
'';
};
overrides = lib.composeManyExtensions
(builtins.map timePhase phases);
in drv.overrideAttrs overrides
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment