Created
January 24, 2023 06:02
-
-
Save rrbutani/b991b50ecaa186ddc05e0176578cb916 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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