-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck.sh
executable file
·34 lines (28 loc) · 870 Bytes
/
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
#! /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;