Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / linter-shell (push) Has been cancelled
Mark stable commit / linter-python (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
- Fix SC1091 by updating ShellCheck source hint to repo path - Keep runtime sourcing from /usr/lib/package-manager unchanged - CI-safe without disabling ShellCheck rules" https://chatgpt.com/share/693edae1-6d84-800f-8556-0e54dd15b944
57 lines
1.9 KiB
Bash
Executable File
57 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
FLAKE_DIR="/usr/lib/package-manager"
|
|
NIX_LIB_DIR="${FLAKE_DIR}/nix/lib"
|
|
RETRY_LIB="${NIX_LIB_DIR}/retry_403.sh"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Hard requirement: retry helper must exist (fail if missing)
|
|
# ---------------------------------------------------------------------------
|
|
if [[ ! -f "${RETRY_LIB}" ]]; then
|
|
echo "[launcher] ERROR: Required retry helper not found: ${RETRY_LIB}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck source=./nix/lib/retry_403.sh
|
|
source "${RETRY_LIB}"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Try to ensure that "nix" is on PATH (common locations + container user)
|
|
# ---------------------------------------------------------------------------
|
|
if ! command -v nix >/dev/null 2>&1; then
|
|
CANDIDATES=(
|
|
"/nix/var/nix/profiles/default/bin/nix"
|
|
"${HOME:-/root}/.nix-profile/bin/nix"
|
|
"/home/nix/.nix-profile/bin/nix"
|
|
)
|
|
|
|
for candidate in "${CANDIDATES[@]}"; do
|
|
if [[ -x "$candidate" ]]; then
|
|
PATH="$(dirname "$candidate"):${PATH}"
|
|
export PATH
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# If nix is still missing, try to run nix/init.sh once
|
|
# ---------------------------------------------------------------------------
|
|
if ! command -v nix >/dev/null 2>&1; then
|
|
if [[ -x "${FLAKE_DIR}/nix/init.sh" ]]; then
|
|
"${FLAKE_DIR}/nix/init.sh" || true
|
|
fi
|
|
fi
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Primary path: use Nix flake if available (with GitHub 403 retry)
|
|
# ---------------------------------------------------------------------------
|
|
if command -v nix >/dev/null 2>&1; then
|
|
exec run_with_github_403_retry nix run "${FLAKE_DIR}#pkgmgr" -- "$@"
|
|
fi
|
|
|
|
echo "[launcher] ERROR: 'nix' binary not found on PATH after init."
|
|
echo "[launcher] Nix is required to run pkgmgr (no Python fallback)."
|
|
exit 1
|