added vm build script

This commit is contained in:
Bryan Ramos 2024-05-13 20:23:55 -04:00
parent 8a9f41e37e
commit 48f223a030
Signed by: bryan
GPG key ID: 6ABDCD144D6643C8

View file

@ -35,7 +35,7 @@ test TYPE="nix" SYSTEM="desktop":
;; ;;
esac esac
# Build the nix expression and hydrate the results directory # Build the nix expression and hydrate the results directory - pass VM flag to build a VM
build TYPE="nix" SYSTEM="desktop": build TYPE="nix" SYSTEM="desktop":
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
@ -60,8 +60,24 @@ build TYPE="nix" SYSTEM="desktop":
nix build --dry-run .#homeConfigurations."workstation".config.home-manager.build.toplevel -L nix build --dry-run .#homeConfigurations."workstation".config.home-manager.build.toplevel -L
exit 0 exit 0
;; ;;
"vm")
if [ "{{SYSTEM}}" = "desktop" ] || [ "{{SYSTEM}}" = "server" ] || [ "{{SYSTEM}}" = "wsl" ] || [ "{{SYSTEM}}" = "laptop" ]; then
echo "Building VM for {{SYSTEM}}..."
nixos-rebuild build-vm --flake .#{{SYSTEM}}
result/bin/run-{{SYSTEM}}-vm
exit 0
else
echo "Error: Unknown argument - '{{SYSTEM}}'"
echo "Use one of:"
echo " desktop"
echo " server"
echo " laptop"
echo " wsl"
exit 1
fi
;;
*) *)
echo "Invalid usage: {{TYPE}}."; echo "Invalid usage: {{TYPE}}."
echo "Use one of:" echo "Use one of:"
echo " nixos" echo " nixos"
echo " home" echo " home"