Init
Initial commit, nodes are mostly done, panel is WIP
This commit is contained in:
commit
67b1571e28
73 files changed
+3410
No files matched your search
@@ -0,0 +1,33 @@
|
||||
select_node() {
|
||||
local raw choice
|
||||
local -a hosts
|
||||
|
||||
raw=$(
|
||||
nix eval --raw .#nixosConfigurations \
|
||||
--apply 'cfgs: builtins.concatStringsSep "\n" (builtins.sort builtins.lessThan (builtins.attrNames cfgs))'
|
||||
)
|
||||
|
||||
mapfile -t hosts <<< "$raw"
|
||||
if ((${#hosts[@]} == 0)) || [[ -z ${hosts[0]} ]]; then
|
||||
echo "No nixosConfigurations in this flake." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local i=1
|
||||
for node in "${hosts[@]}"; do
|
||||
printf '%d) %s\n' "$i" "$node" >&2
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
read -r -p "Host number: " choice
|
||||
if [[ ! $choice =~ ^[0-9]+$ ]]; then
|
||||
echo "Not a number: ${choice}" >&2
|
||||
return 1
|
||||
fi
|
||||
if ((10#$choice < 1 || 10#$choice > ${#hosts[@]})); then
|
||||
echo "Out of range: ${choice}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
printf '%s\n' "${hosts[10#$choice - 1]}"
|
||||
}
|
||||
Reference in new issue
Block a user