deploy: function for listing hosts

This commit is contained in:
Aaron Bieber 2022-10-05 07:33:13 -06:00
parent 3fbcf03c7c
commit 751c167fa4
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View File

@ -8,6 +8,14 @@ msg() {
echo -e "===> $@"
}
listNixOSHosts() {
for i in $(nix eval .#nixosConfigurations --apply builtins.attrNames --json | jq -r '.[]'); do
if [ -d hosts/${i} ]; then
echo $i
fi
done
}
resolveAlias() {
host="${1}"
if [ -f hosts/${host}/alias ]; then

4
deploy
View File

@ -34,7 +34,7 @@ rebuild() {
if [ "$1" = "status" ]; then
rev=$(git rev-parse HEAD)
msg "Currently at: ${rev}\t($(git log --format=%B -n 1 $rev | head -n1))"
for h in $(nix eval .#nixosConfigurations --apply builtins.attrNames --json | jq -r '.[]'); do
for h in $(listNixOSHosts); do
host="$(resolveAlias $h)"
if ! tsAlive $host; then
msg "can't reach ${host}.. skipping.."
@ -126,7 +126,7 @@ ret=0
if [ ${#@} = 1 ]; then
rebuild $1 true || ret=1
else
for host in $(nix eval .#nixosConfigurations --apply builtins.attrNames --json | jq -r '.[]'); do
for host in $(listNixOSHosts); do
rebuild $host false || ret=1
done
fi