From 3ba5ef91bc9de8ddd302124e3415192b186f6703 Mon Sep 17 00:00:00 2001 From: piegames Date: Tue, 15 Oct 2024 23:34:20 +0200 Subject: [PATCH] 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 --- bench/bench.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 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 -# XXX: yes this is very silly. flakes~!! -nix build --impure --expr '(builtins.getFlake "git+file:.").inputs.nixpkgs.outPath' -o bench/nixpkgs +flake_args=("--extra-experimental-features" "nix-command flakes") +# 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)" _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[*]}")"