aboutsummaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorpiegames <git@piegames.de>2024-10-15 23:34:20 +0200
committerpiegames <git@piegames.de>2024-10-18 19:37:23 +0200
commit3ba5ef91bc9de8ddd302124e3415192b186f6703 (patch)
tree88a6536e170435dcf32b30ce4a24829f2439a53f /bench
parente5de1d13c493f80ff6cd21c51f77a4ed10088ea2 (diff)
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
Diffstat (limited to 'bench')
-rwxr-xr-xbench/bench.sh12
1 files changed, 9 insertions, 3 deletions
diff --git a/bench/bench.sh b/bench/bench.sh
index 70acd4640..15d8af05a 100755
--- a/bench/bench.sh
+++ b/bench/bench.sh
@@ -1,4 +1,5 @@
-#!/usr/bin/env bash
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p bash -p hyperfine
set -euo pipefail
shopt -s inherit_errexit
@@ -21,16 +22,21 @@ fi
_exit=""
trap "$_exit" EXIT
+flake_args=("--extra-experimental-features" "nix-command flakes")
+
# XXX: yes this is very silly. flakes~!!
-nix build --impure --expr '(builtins.getFlake "git+file:.").inputs.nixpkgs.outPath' -o bench/nixpkgs
+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)"
_exit='rm -rfv "$NIX_REMOTE"; $_exit'
export NIX_PATH="nixpkgs=bench/nixpkgs:nixos-config=bench/configuration.nix"
builds=("$@")
-flake_args="--extra-experimental-features 'nix-command flakes'"
+flake_args="${flake_args[*]@Q}"
hyperfineArgs=(
--parameter-list BUILD "$(IFS=,; echo "${builds[*]}")"