34 lines
1.0 KiB
Bash
Executable File
34 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Default output path
|
|
OUTPUT_PATH="${HOME}/.deno/bin/pmpr"
|
|
|
|
# Ensure directory exists
|
|
mkdir -p "$(dirname "$OUTPUT_PATH")"
|
|
|
|
# Check if we are on a system that needs patching (like NixOS)
|
|
IS_NIXOS=false
|
|
if [ "$(uname)" = "Linux" ]; then
|
|
if [ ! -f /lib64/ld-linux-x86-64.so.2 ] || ls -l /lib64/ld-linux-x86-64.so.2 | grep -q "stub-ld"; then
|
|
IS_NIXOS=true
|
|
fi
|
|
fi
|
|
|
|
if [ "$IS_NIXOS" = true ]; then
|
|
echo "NixOS detected. Creating a wrapper script instead of a compiled binary to avoid linking issues with Deno."
|
|
# Use absolute paths for config and script to make it work from anywhere
|
|
PROJECT_ROOT="$(pwd)"
|
|
cat > "$OUTPUT_PATH" <<EOF
|
|
#!/usr/bin/env bash
|
|
# PolyMPR CLI Wrapper for Nix
|
|
exec deno run -A --config "$PROJECT_ROOT/deno.json" "$PROJECT_ROOT/toolbox/cli.ts" "\$@"
|
|
EOF
|
|
chmod +x "$OUTPUT_PATH"
|
|
echo "Wrapper created at $OUTPUT_PATH"
|
|
else
|
|
echo "Compiling CLI to $OUTPUT_PATH..."
|
|
deno compile -A --output "$OUTPUT_PATH" toolbox/cli.ts
|
|
echo "Done."
|
|
fi
|