whatsupnix: add support for remote hosts
This commit is contained in:
parent
1f8ef7803e
commit
a74be81827
@ -1,4 +1,4 @@
|
|||||||
{ bash, coreutils, gawk, nix, makeWrapper, stdenv }:
|
{ bash, coreutils, gawk, makeWrapper, nix, openssh, stdenv }:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "whatsupnix";
|
name = "whatsupnix";
|
||||||
@ -8,7 +8,7 @@ stdenv.mkDerivation {
|
|||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cat - ${./whatsupnix.bash} > $out/bin/whatsupnix <<\EOF
|
cat - ${./whatsupnix.bash} > $out/bin/whatsupnix <<\EOF
|
||||||
#! ${bash}/bin/bash
|
#! ${bash}/bin/bash
|
||||||
export PATH=${stdenv.lib.makeBinPath [ coreutils gawk nix ]}
|
export PATH=${stdenv.lib.makeBinPath [ coreutils gawk nix openssh ]}
|
||||||
EOF
|
EOF
|
||||||
chmod +x $out/bin/whatsupnix
|
chmod +x $out/bin/whatsupnix
|
||||||
'';
|
'';
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
# set -o pipefail
|
# set -o pipefail
|
||||||
# nix-build ... -Q ... | whatsupnix
|
# nix-build ... -Q ... | whatsupnix [user@target[:port]]
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
@ -18,17 +18,46 @@ trap 'rm -f -- "$broken"' EXIT
|
|||||||
|
|
||||||
exec >&2
|
exec >&2
|
||||||
|
|
||||||
$GAWK -v broken="$broken" -f <(cat - <<- 'AWK'
|
$GAWK -v broken="$broken" '
|
||||||
match($0, /builder for .*(\/nix\/store\/.+\.drv).* failed/, m) {
|
match($0, /^builder for ‘(\/nix\/store\/[^’]+\.drv)’ failed/, m) {
|
||||||
print m[1] >> broken
|
print m[1] >> broken
|
||||||
}
|
}
|
||||||
{ print $0 }
|
{ print $0 }
|
||||||
AWK
|
'
|
||||||
)
|
|
||||||
|
case $# in
|
||||||
|
0)
|
||||||
|
print_log() {
|
||||||
|
$NIX_STORE -l "$1"
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
remote_user=${1%%@*}
|
||||||
|
if test "$remote_user" = "$1"; then
|
||||||
|
remote_user=root
|
||||||
|
else
|
||||||
|
set -- "${1#$remote_user@}"
|
||||||
|
fi
|
||||||
|
remote_port=${1##*:}
|
||||||
|
if test "$remote_port" = "$1"; then
|
||||||
|
remote_port=22
|
||||||
|
else
|
||||||
|
set -- "${1%:$remote_port}"
|
||||||
|
fi
|
||||||
|
remote_host=$1
|
||||||
|
print_log() {
|
||||||
|
ssh "$remote_user@$remote_host" -p "$remote_port" \
|
||||||
|
nix-store -l "$1"
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "usage: whatsupnix [[USER@]HOST[:PORT]]" >&2
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
export NIX_PAGER='' # for nix-store
|
export NIX_PAGER='' # for nix-store
|
||||||
while read -r drv; do
|
while read -r drv; do
|
||||||
title="** FAILED $drv LOG **"
|
title="** FAILED $drv LOG **"
|
||||||
frame=${title//?/*}
|
frame=${title//?/*}
|
||||||
|
|
||||||
echo "$frame"
|
echo "$frame"
|
||||||
@ -36,7 +65,7 @@ while read -r drv; do
|
|||||||
echo "$frame"
|
echo "$frame"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
$NIX_STORE -l "$drv"
|
print_log "$drv"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
done < "$broken"
|
done < "$broken"
|
||||||
|
Loading…
Reference in New Issue
Block a user