nix-bitcoin/test/nixos-search/flake-info-sandboxed.sh
Jonas Nick f26216b624 update nixpkgs
btcpayserver: 1.7.3 -> 1.7.12
elementsd: 22.0.2 -> 22.1
nbxplorer: 2.3.54 -> 2.3.62

Also add new required argument to flake-info in CI test script.
2023-06-01 02:56:23 -07:00

45 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Run flake-info for the nix-bitcoin flake in a sandbox:
# - Adds a consistent, reproducible runtime environment
# - Removes the need to trust the flake-info binary
#
# Use bubblewrap instead of a sandboxed Nix build so that we don't have to copy
# the whole repo to the sandbox when running this test.
cd "${BASH_SOURCE[0]%/*}"
nbFlake=$(realpath ../..)
# shellcheck disable=SC2016
PATH=$(nix shell -L .#{flake-info,bubblewrap} -c sh -c 'echo $PATH')
tmpDir=$(mktemp -d /tmp/nix-bitcoin-flake-info.XXX)
trap 'rm -rf $tmpDir' EXIT
echo '
experimental-features = nix-command flakes
flake-registry = /dev/null
' > "$tmpDir/nix.conf"
echo "Running flake-info (nixos-search)"
bwrap \
--unshare-all \
--clearenv \
--setenv PATH "$PATH" \
--setenv NIX_PATH "$NIX_PATH" \
--bind "$tmpDir" / \
--proc /proc \
--dev /dev \
--tmpfs /tmp \
--ro-bind "$nbFlake" "$nbFlake" \
--ro-bind /nix /nix \
--ro-bind /etc /etc \
--tmpfs /etc/nix \
--ro-bind "$tmpDir/nix.conf" /etc/nix/nix.conf \
--ro-bind /usr /usr \
--ro-bind-try /run /run \
-- flake-info --json flake "$nbFlake" >/dev/null