2025-12-06 19:32:31 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
2025-12-07 20:36:39 +01:00
|
|
|
FLAKE_DIR="/usr/lib/package-manager"
|
|
|
|
|
|
2025-12-11 18:33:02 +01:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Try to ensure that "nix" is on PATH (common locations + container user)
|
|
|
|
|
# ---------------------------------------------------------------------------
|
2025-12-09 05:31:55 +01:00
|
|
|
if ! command -v nix >/dev/null 2>&1; then
|
|
|
|
|
CANDIDATES=(
|
|
|
|
|
"/nix/var/nix/profiles/default/bin/nix"
|
|
|
|
|
"${HOME:-/root}/.nix-profile/bin/nix"
|
2025-12-11 18:33:02 +01:00
|
|
|
"/home/nix/.nix-profile/bin/nix"
|
2025-12-09 05:31:55 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
for candidate in "${CANDIDATES[@]}"; do
|
|
|
|
|
if [[ -x "$candidate" ]]; then
|
|
|
|
|
PATH="$(dirname "$candidate"):${PATH}"
|
|
|
|
|
export PATH
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2025-12-11 18:33:02 +01:00
|
|
|
# ---------------------------------------------------------------------------
|
2025-12-12 20:47:31 +01:00
|
|
|
# If nix is still missing, try to run nix/init.sh once
|
2025-12-11 18:33:02 +01:00
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
if ! command -v nix >/dev/null 2>&1; then
|
2025-12-12 20:47:31 +01:00
|
|
|
if [[ -x "${FLAKE_DIR}/nix/init.sh" ]]; then
|
|
|
|
|
"${FLAKE_DIR}/nix/init.sh" || true
|
2025-12-11 18:33:02 +01:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
# Primary path: use Nix flake if available
|
|
|
|
|
# ---------------------------------------------------------------------------
|
2025-12-09 05:31:55 +01:00
|
|
|
if command -v nix >/dev/null 2>&1; then
|
|
|
|
|
exec nix run "${FLAKE_DIR}#pkgmgr" -- "$@"
|
|
|
|
|
fi
|
|
|
|
|
|
2025-12-13 21:25:02 +01:00
|
|
|
echo "[launcher] ERROR: 'nix' binary not found on PATH after init."
|
|
|
|
|
echo "[launcher] Nix is required to run pkgmgr (no Python fallback)."
|
2025-12-09 05:31:55 +01:00
|
|
|
exit 1
|