Use QVM_BIN_DIR fallback for script paths and set in flake

This commit is contained in:
Joshua Bell 2026-01-26 10:27:57 -06:00
parent 8d68e1daf9
commit 7864673dcb
6 changed files with 13 additions and 14 deletions

View file

@ -21,8 +21,7 @@ readonly QVM_LIB_DIR="${QVM_LIB_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../lib
source "${QVM_LIB_DIR}/common.sh"
# Get path to qvm-stop script
readonly QVM_BIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly QVM_STOP="${QVM_BIN_DIR}/qvm-stop"
readonly QVM_STOP="${QVM_BIN_DIR:-$(dirname "$0")}/qvm-stop"
#
# confirm_clean - Prompt user for confirmation

View file

@ -20,8 +20,7 @@ readonly QVM_LIB_DIR="${QVM_LIB_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../lib
source "${QVM_LIB_DIR}/common.sh"
# Get path to qvm-stop script
readonly QVM_BIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly QVM_STOP="${QVM_BIN_DIR}/qvm-stop"
readonly QVM_STOP="${QVM_BIN_DIR:-$(dirname "$0")}/qvm-stop"
#
# confirm_reset - Prompt user for confirmation

View file

@ -159,6 +159,9 @@ main() {
exit 0
fi
# Ensure directories exist before accessing workspaces.json
ensure_dirs
# If no command given, default to interactive zsh shell
local run_shell=false
if [[ $# -eq 0 ]]; then
@ -188,10 +191,8 @@ main() {
if [[ "$newly_added" -eq 1 ]] && is_vm_running; then
log_info "New workspace registered. Restarting VM to mount it..."
# Path to qvm-stop and qvm-start scripts
local script_dir="${QVM_LIB_DIR}/../bin"
local qvm_stop="$script_dir/qvm-stop"
local qvm_start="$script_dir/qvm-start"
local qvm_stop="${QVM_BIN_DIR:-$(dirname "$0")}/qvm-stop"
local qvm_start="${QVM_BIN_DIR:-$(dirname "$0")}/qvm-start"
# Stop the VM
if ! "$qvm_stop"; then
@ -210,8 +211,7 @@ main() {
if ! is_vm_running; then
log_info "VM not running, starting..."
# Path to qvm-start script
local qvm_start="${QVM_LIB_DIR}/../bin/qvm-start"
local qvm_start="${QVM_BIN_DIR:-$(dirname "$0")}/qvm-start"
if ! "$qvm_start"; then
die "Failed to start VM"

View file

@ -78,7 +78,7 @@ main() {
# Ensure VM is running (auto-start if needed)
if ! is_vm_running; then
log_info "VM is not running, starting it..."
"$QVM_LIB_DIR/../bin/qvm-start"
" "${QVM_BIN_DIR:-$(dirname "$0")}/qvm-start""
fi
# Get SSH port

View file

@ -130,8 +130,8 @@ main() {
log_info "First run detected - building VM..."
log_info "This may take several minutes."
SCRIPT_DIR="$(dirname "$0")"
if ! "$SCRIPT_DIR/qvm-rebuild"; then
local qvm_rebuild="${QVM_BIN_DIR:-$(dirname "$0")}/qvm-rebuild"
if ! "$qvm_rebuild"; then
die "Failed to build VM. Run 'qvm rebuild' manually to debug."
fi
fi

View file

@ -109,7 +109,8 @@
pkgs.sshpass
]
} \
--set QVM_LIB_DIR "$out/lib/qvm"
--set QVM_LIB_DIR "$out/lib/qvm" \
--set QVM_BIN_DIR "$out/bin"
done
runHook postInstall