-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.sh
executable file
·42 lines (34 loc) · 1.06 KB
/
check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /usr/bin/env bash
set -eu;
set -o pipefail;
: "${REALPATH:=realpath}";
: "${NIX:=nix}";
: "${NIX_FLAGS:=--no-warn-dirty}";
: "${NIX_CMD_FLAGS:=-L --show-trace}";
: "${SYSTEM:=$( $NIX eval --raw --impure --expr builtins.currentSystem; )}";
: "${GREP:=grep}"
: "${JQ:=jq}";
SDIR="$( $REALPATH "${BASH_SOURCE[0]}" )";
SDIR="${SDIR%/*}";
: "${FLAKE_REF:=$SDIR}";
trap '_es="$?"; exit "$_es";' HUP EXIT INT QUIT ABRT;
nix_w() {
{
{
$NIX $NIX_FLAGS "$@" 3>&2 2>&1 1>&3||exit 1;
}|$GREP -v 'warning: unknown flake output';
} 3>&2 2>&1 1>&3;
}
nix_w flake check "$FLAKE_REF" $NIX_CMD_FLAGS --system "$SYSTEM";
nix_w flake check "$FLAKE_REF" $NIX_CMD_FLAGS --system "$SYSTEM" --impure;
# Swallow traces, but show them on failure.
check_lib() {
nix_w eval "$FLAKE_REF#lib" --apply 'lib: builtins.deepSeq lib true';
}
check_lib 2>/dev/null||check_lib;
export NIX NIX_FLAGS REALPATH JQ FLAKE_REF;
# Script tests
printf 'tests/prefetch/fallback.sh:\n';
$SDIR/tests/prefetch/fallback.sh;
printf 'tests/prefetch/no-fallback.sh:\n';
$SDIR/tests/prefetch/no-fallback.sh;