#!/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 # ------------------------------------------------------------ if ! command -v nix >/dev/null 2>&1; then # Common locations for Nix installations CANDIDATES=( "/nix/var/nix/profiles/default/bin/nix" "${HOME:-/root}/.nix-profile/bin/nix" ) for candidate in "${CANDIDATES[@]}"; do if [[ -x "$candidate" ]]; then # Prepend the directory of the candidate to PATH PATH="$(dirname "$candidate"):${PATH}" export PATH break fi done fi # ------------------------------------------------------------ # Primary (and only) 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." echo "[pkgmgr-wrapper] Nix is required to run pkgmgr (no Python fallback)." exit 1