init
This commit is contained in:
commit
dc5069e9b2
7 changed files with 323 additions and 0 deletions
38
scripts/run-vm.sh
Normal file
38
scripts/run-vm.sh
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if ! command -v gum &> /dev/null; then
|
||||
echo "gum (from charm.sh) is required but not found in PATH."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo "jq is required but not found in PATH."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# List flake configs without evaluating them
|
||||
HOSTS=()
|
||||
while IFS= read -r line; do
|
||||
HOSTS+=("$line")
|
||||
done < <(nix flake show --json | jq -r '.nixosConfigurations | keys[]')
|
||||
|
||||
if [ ${#HOSTS[@]} -eq 0 ]; then
|
||||
echo "No NixOS configurations found in flake."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prompt user for a config
|
||||
SELECTED=$(printf "%s\n" "${HOSTS[@]}" | gum choose --header="Select a NixOS VM config:")
|
||||
|
||||
if [ -z "$SELECTED" ]; then
|
||||
echo "No hostname selected. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Building VM for flake config: $SELECTED"
|
||||
|
||||
# Build the VM
|
||||
nix run ".#nixosConfigurations.$SELECTED.config.system.build.vm"
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue