summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--krebs/5pkgs/simple/whatsupnix/default.nix4
-rw-r--r--krebs/5pkgs/simple/whatsupnix/whatsupnix.bash43
-rw-r--r--tv/2configs/bash/completion.sh (renamed from tv/2configs/bash_completion.sh)0
-rw-r--r--tv/2configs/bash/default.nix (renamed from tv/2configs/bash.nix)0
-rw-r--r--tv/2configs/default.nix2
6 files changed, 45 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 09f6eafd7..ce6205c5b 100644
--- a/Makefile
+++ b/Makefile
@@ -83,7 +83,12 @@ deploy:
$(MAKE) populate debug=false
$(ssh) $(target_user)@$(target_host) -p $(target_port) \
env STOCKHOLM_VERSION="$$STOCKHOLM_VERSION" \
- nixos-rebuild $(rebuild-command) --show-trace -I $(target_path)
+ nixos-rebuild -Q $(rebuild-command) --show-trace -I $(target_path) \
+ |& if type whatsupnix 2>/dev/null; then \
+ whatsupnix $(target_user)@$(target_host):$(target_port); \
+ else \
+ cat; \
+ fi
# usage: make populate system=foo
populate: populate-target = \
diff --git a/krebs/5pkgs/simple/whatsupnix/default.nix b/krebs/5pkgs/simple/whatsupnix/default.nix
index 1a108c5e9..62ef597c8 100644
--- a/krebs/5pkgs/simple/whatsupnix/default.nix
+++ b/krebs/5pkgs/simple/whatsupnix/default.nix
@@ -1,4 +1,4 @@
-{ bash, coreutils, gawk, nix, makeWrapper, stdenv }:
+{ bash, coreutils, gawk, makeWrapper, nix, openssh, stdenv }:
stdenv.mkDerivation {
name = "whatsupnix";
@@ -8,7 +8,7 @@ stdenv.mkDerivation {
mkdir -p $out/bin
cat - ${./whatsupnix.bash} > $out/bin/whatsupnix <<\EOF
#! ${bash}/bin/bash
- export PATH=${stdenv.lib.makeBinPath [ coreutils gawk nix ]}
+ export PATH=${stdenv.lib.makeBinPath [ coreutils gawk nix openssh ]}
EOF
chmod +x $out/bin/whatsupnix
'';
diff --git a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
index a19410055..eba44be1c 100644
--- a/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
+++ b/krebs/5pkgs/simple/whatsupnix/whatsupnix.bash
@@ -6,7 +6,7 @@
# Usage:
#
# 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
-$GAWK -v broken="$broken" -f <(cat - <<- 'AWK'
- match($0, /builder for .*(\/nix\/store\/.+\.drv).* failed/, m) {
+$GAWK -v broken="$broken" '
+ match($0, /^builder for ‘(\/nix\/store\/[^’]+\.drv)’ failed/, m) {
print m[1] >> broken
}
{ 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
while read -r drv; do
- title="** FAILED $drv LOG **"
+ title="** FAILED $drv LOG **"
frame=${title//?/*}
echo "$frame"
@@ -36,7 +65,7 @@ while read -r drv; do
echo "$frame"
echo
- $NIX_STORE -l "$drv"
+ print_log "$drv"
echo
done < "$broken"
diff --git a/tv/2configs/bash_completion.sh b/tv/2configs/bash/completion.sh
index 537484fb9..537484fb9 100644
--- a/tv/2configs/bash_completion.sh
+++ b/tv/2configs/bash/completion.sh
diff --git a/tv/2configs/bash.nix b/tv/2configs/bash/default.nix
index 40c0725ed..40c0725ed 100644
--- a/tv/2configs/bash.nix
+++ b/tv/2configs/bash/default.nix
diff --git a/tv/2configs/default.nix b/tv/2configs/default.nix
index d16ff4eb5..b2560084d 100644
--- a/tv/2configs/default.nix
+++ b/tv/2configs/default.nix
@@ -27,7 +27,7 @@ with import <stockholm/lib>;
<secrets>
./audit.nix
./backup.nix
- ./bash.nix
+ ./bash
./htop.nix
./nginx
./ssh.nix