diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index c5063003c4..14aa5b9c47 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -4,6 +4,11 @@ steps: agents: system: x86_64-linux + - label: 'Run profile with ghc8107' + command: "nix shell github:Kha/nixprof -c ./test/profile.sh ghc8107" + agents: + system: x86_64-linux + - label: 'Check that jobset will evaluate in Hydra' command: - nix-build build.nix -A maintainer-scripts.check-hydra -o check-hydra.sh diff --git a/test/profile.sh b/test/profile.sh new file mode 100755 index 0000000000..55b1f0b4e2 --- /dev/null +++ b/test/profile.sh @@ -0,0 +1,34 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p bash jq nix gnused + +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