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-container (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 / mark-stable (push) Has been cancelled
- Extend PATH probing to include /home/nix/.nix-profile/bin/nix (container mode). - Automatically invoke init-nix.sh when nix is not found before first run. - Ensure pkgmgr always attempts a one-time Nix initialization instead of failing prematurely. - Improve error message to clarify that nix was still missing *after* initialization attempt. - Keep existing flake-based execution path unchanged (exec nix run …). This makes the wrapper fully reliable across Debian/Ubuntu package installs, fresh containers, and minimal systems where Nix is not yet initialized. https://chatgpt.com/share/693b005d-b250-800f-8830-ab71685f51b3
49 lines
1.6 KiB
Bash
Executable File
49 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Ensure NIX_CONFIG has our defaults if not already set
|
|
if [[ -z "${NIX_CONFIG:-}" ]]; then
|
|
export NIX_CONFIG="experimental-features = nix-command flakes"
|
|
fi
|
|
|
|
FLAKE_DIR="/usr/lib/package-manager"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# 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 init-nix.sh once
|
|
# ---------------------------------------------------------------------------
|
|
if ! command -v nix >/dev/null 2>&1; then
|
|
if [[ -x "${FLAKE_DIR}/init-nix.sh" ]]; then
|
|
"${FLAKE_DIR}/init-nix.sh" || true
|
|
fi
|
|
fi
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Primary path: use Nix flake if available
|
|
# ---------------------------------------------------------------------------
|
|
if command -v nix >/dev/null 2>&1; then
|
|
exec nix run "${FLAKE_DIR}#pkgmgr" -- "$@"
|
|
fi
|
|
|
|
echo "[pkgmgr-wrapper] ERROR: 'nix' binary not found on PATH after init."
|
|
echo "[pkgmgr-wrapper] Nix is required to run pkgmgr (no Python fallback)."
|
|
exit 1
|