-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up a simple CI profiling step using
nixprof
- Loading branch information
1 parent
e36a34c
commit 5baa3b8
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#! /usr/bin/env nix shell nixpkgs#bash nixpkgs#jq github:Kha/nixprof | ||
|
||
set -euo pipefail | ||
|
||
# check if Nix has the `ca-derivations` experimental features (code 0) is enabled | ||
NIX_CA_DERIVATIONS=$(jq -e '."experimental-features".value|any(. == 0)' <<< $(nix show-config --json)) || true | ||
NIX_BUILD_ARGS="${NIX_BUILD_ARGS:-}" | ||
|
||
cd $(dirname $0) | ||
|
||
if [ "$#" != "1" ]; then | ||
echo "Please pass a compiler-nix-name to use. For example: ./test/profile.sh ghc884" | ||
exit 1 | ||
fi | ||
|
||
GHC=$1 | ||
|
||
printf "*** Cleaning package build directories..." >& 2 | ||
rm -rvf */cabal.project.local */.ghc.environment* */dist */dist-newstyle */.stack-work | ||
echo >& 2 | ||
|
||
printf "*** Profile the nix build...\n" >& 2 | ||
nixprof record nix build $NIX_BUILD_ARGS \ | ||
-I . -I .. \ | ||
--option restrict-eval true \ | ||
--option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \ | ||
--no-link --keep-going -f default.nix \ | ||
--argstr compiler-nix-name $GHC \ | ||
--arg CADerivationsEnabled $NIX_CA_DERIVATIONS | ||
nixprof report | ||
echo >& 2 | ||
|
||
printf "\n*** Finished successfully\n" >& 2 |