aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/system_info.sh
blob: f0de42ba29fa3c4ea949693c96affbf389a554e3 (plain) (blame)
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
#!/usr/bin/env sh

root="$(git rev-parse --show-toplevel)"

# Take a host name and return the nix store path to the host's system info.
# Type
# _system_info :: String -> Path
_system_info() {
    nix --option warn-dirty false build .#nixosConfigurations."$1".config.vhack.system-info.markdown --print-out-paths --no-link
}

_glow() {
    if command -v glow >/dev/null; then
        glow --width 0
    else
        cat
    fi
}

# The expression is not meant to be expanded by the shell
# shellcheck disable=SC2016
fd . "$root/hosts/by-name" --type directory --max-depth 1 | while read -r host_path; do
    host="$(basename "$host_path")"
    echo "# $host" | _glow
    _glow <"$(_system_info "$host")"
done

# vim: ft=sh