-
Notifications
You must be signed in to change notification settings - Fork 0
/
examine-attr.sh
executable file
·43 lines (36 loc) · 1 KB
/
examine-attr.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
43
#!/bin/sh
## Usage: ATTR [--verbose] Show basic properties of a Haskell attribute
basename=$(basename $0)
nhroot="$(realpath $0 | xargs dirname)"
attr="$1"
test -n "$attr" || { echo "USAGE: ${basename} ATTR" >&2; exit 1; }
shift
verbose=""
while test -n "$1"
do case "$1" in
--verbose ) verbose=yes;;
"" ) break;;
esac; shift; done
compiler=$(cat "${nhroot}/default-compiler.nix")
NIX_ARGS="-A pkgs.haskell.packages."${compiler}"."${attr}" ${nhroot}/nixpkgs.nix"
drv=$(nix-instantiate --quiet ${NIX_ARGS} "$@" || true)
if ! test -n "${drv}"
then
echo "### Instantiation failed:" >&2
cat $LOG >&2
echo "### Instantiation failed" >&2
exit 1
fi
cat <<EOF
attr: ${attr}
compiler: ${compiler}
store derivation: ${drv}
output: $(nix-store --query --binding out ${drv})
src derivation: $(nix-store --query --binding src ${drv})
EOF
if test -n "${verbose}"
then cat <<EOF
inputs:
EOF
nix-store --query --references ${drv}
fi