benchmarks: Fix purity

Some stuff wasn't working on my machine because it depended on the host
environment in some ways, fixed those.

Change-Id: Iff4931a9a26c6827978f1ee6434710f406d67a96
This commit is contained in:
piegames 2024-10-15 23:34:20 +02:00
parent e5de1d13c4
commit 3ba5ef91bc

View file

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p hyperfine
set -euo pipefail set -euo pipefail
shopt -s inherit_errexit shopt -s inherit_errexit
@ -21,16 +22,21 @@ fi
_exit="" _exit=""
trap "$_exit" EXIT trap "$_exit" EXIT
# XXX: yes this is very silly. flakes~!! flake_args=("--extra-experimental-features" "nix-command flakes")
nix build --impure --expr '(builtins.getFlake "git+file:.").inputs.nixpkgs.outPath' -o bench/nixpkgs
# XXX: yes this is very silly. flakes~!!
nix build "${flake_args[@]}" --impure --expr '(builtins.getFlake "git+file:.").inputs.nixpkgs.outPath' -o bench/nixpkgs
# We must ignore the global config, or else NIX_PATH won't work reliably.
# See https://github.com/NixOS/nix/issues/9574
export NIX_CONF_DIR='/var/empty'
export NIX_REMOTE="$(mktemp -d)" export NIX_REMOTE="$(mktemp -d)"
_exit='rm -rfv "$NIX_REMOTE"; $_exit' _exit='rm -rfv "$NIX_REMOTE"; $_exit'
export NIX_PATH="nixpkgs=bench/nixpkgs:nixos-config=bench/configuration.nix" export NIX_PATH="nixpkgs=bench/nixpkgs:nixos-config=bench/configuration.nix"
builds=("$@") builds=("$@")
flake_args="--extra-experimental-features 'nix-command flakes'" flake_args="${flake_args[*]@Q}"
hyperfineArgs=( hyperfineArgs=(
--parameter-list BUILD "$(IFS=,; echo "${builds[*]}")" --parameter-list BUILD "$(IFS=,; echo "${builds[*]}")"