python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / nix / info / info.sh
blobc309e8be1649fbc5f703523e52df121a88c23363
1 #!/bin/bash
3 PATH="@path@:$PATH"
4 IS_DARWIN="@is_darwin@"
6 set -eu
7 set -o pipefail
9 DEBUG=0
10 MARKDOWN=0
11 HOST_OS=0
12 SANDBOX=0
13 while true; do
14 case "${1:-}" in
15 "")
16 break
18 -d | --debug)
19 set -x
20 DEBUG=1
21 shift
23 -m | --markdown)
24 MARKDOWN=1
25 HOST_OS=1
26 SANDBOX=1
27 shift
29 --host-os)
30 HOST_OS=1
31 shift
33 --sandbox)
34 SANDBOX=1
35 shift
38 * )
39 cat <<EOF
40 nix-info - get high level info to help with debugging
42 Options:
44 -m, --markdown formatting for a GitHub issue
45 implies: --host-os, --sandbox
47 --sandbox include sandbox configuration
48 --host-os include host OS details
50 -h, --help show this message
51 -d, --debug debug mode
53 EOF
54 exit 1
57 esac
58 done
60 debuglog() {
61 if [ $DEBUG -eq 1 ]; then
62 cat >&2
63 else
64 cat > /dev/null
68 nixev() {
69 nix-instantiate --eval --strict -E "$1"
72 desc_system() {
73 nixev '(import <nixpkgs> {}).stdenv.hostPlatform.system'
76 desc_host_os() {
77 printf "%s" "$(uname -sr)"
79 if [ "$IS_DARWIN" = "yes" ]; then
80 printf ", macOS %s" "$(sw_vers -productVersion)"
83 if [ -f /etc/os-release ]; then
85 # shellcheck disable=SC1091
86 . /etc/os-release
87 printf ", %s, %s, %s" "${NAME:-$(uname -v)}" "${VERSION:-noversion}" "${BUILD_ID:-nobuild}"
92 desc_multi_user() {
93 if nix-build --no-out-link @multiusertest@ 2>&1 | debuglog; then
94 printf "yes"
95 else
96 printf "no"
100 desc_nixpkgs_path() {
101 nixev '<nixpkgs>'
104 channel_facts() {
105 find /nix/var/nix/profiles/per-user \
106 -mindepth 2 \
107 -maxdepth 2 \
108 -name channels \
109 -print0 \
111 while IFS= read -r -d '' userchannelset; do
112 manifest="$userchannelset/manifest.nix"
114 if [ -e "$manifest" ]; then
115 userchannels=$(nixev \
116 "builtins.concatStringsSep \", \"
117 (map (ch: ch.name)
118 (import \"$manifest\"))")
120 fact "channels($(echo "$manifest" | cut -d/ -f7))" \
121 "$userchannels"
123 done
126 desc_sandbox() {
127 if nix-build --no-out-link @sandboxtest@ 2>&1 | debuglog; then
128 printf "no"
129 elif nix-build --no-out-link @relaxedsandboxtest@ 2>&1 | debuglog; then
130 printf "relaxed"
131 else
132 printf "yes"
136 fact() {
137 name="${1:-0}"
138 value="${2:-0}"
139 last="${3:-1}"
140 if [ $MARKDOWN -eq 0 ]; then
141 printf "%s: %s" "$name" "$value"
142 if [ "$last" -eq 1 ]; then
143 printf ", "
145 else
146 printf " - %s: \`%s\`\\n" "$name" "$value"
149 if [ "$last" -eq 0 ]; then
150 echo ""
154 last_fact() {
155 fact "$1" "$2" 0
158 fact "system" "$(desc_system)"
159 if [ $HOST_OS -eq 1 ]; then
160 fact "host os" "$(desc_host_os)"
162 fact "multi-user?" "$(desc_multi_user)"
163 if [ $SANDBOX -eq 1 ]; then
164 fact "sandbox" "$(desc_sandbox)"
167 fact "version" "$(nix-env --version)"
168 channel_facts
169 last_fact "nixpkgs" "$(desc_nixpkgs_path)"