2024-08-12 01:15:17 +00:00
|
|
|
# shellcheck disable=SC2148
|
2024-08-04 22:03:09 +00:00
|
|
|
function nxr() {
|
|
|
|
set -u
|
|
|
|
|
|
|
|
local pkg=""
|
|
|
|
local bin=""
|
2024-08-12 01:15:17 +00:00
|
|
|
|
2024-08-04 22:03:09 +00:00
|
|
|
local count=0
|
2024-08-12 01:15:17 +00:00
|
|
|
for var in "$@"; do
|
|
|
|
if [ "$var" == "--" ]; then
|
|
|
|
count=$((count + 1))
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$count" == "0" ]; then
|
|
|
|
pkg="$var"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$count" == "1" ]; then
|
|
|
|
bin="$var"
|
|
|
|
fi
|
2024-08-04 22:03:09 +00:00
|
|
|
|
2024-08-12 01:15:17 +00:00
|
|
|
count=$((count + 1))
|
|
|
|
done
|
2024-08-04 22:03:09 +00:00
|
|
|
|
2024-08-12 01:15:17 +00:00
|
|
|
shift $count
|
|
|
|
|
|
|
|
if [ -z "$pkg" ]; then
|
|
|
|
echo "Error: no pkg name given"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-08-04 22:03:09 +00:00
|
|
|
|
|
|
|
if [ -z "$bin" ]; then
|
2024-08-12 01:15:17 +00:00
|
|
|
bin="$pkg"
|
2024-08-04 22:03:09 +00:00
|
|
|
fi
|
|
|
|
|
2024-08-12 01:15:17 +00:00
|
|
|
echo "Running nxr with:"
|
|
|
|
printf "\tpkg=%s" "$pkg"
|
|
|
|
printf "\tbin=%s" "$bin"
|
|
|
|
printf "\topts=%s" "$@"
|
|
|
|
printf "\n\n"
|
|
|
|
|
|
|
|
nix-shell -p "$pkg" --run "$bin $*"
|
2024-08-04 22:03:09 +00:00
|
|
|
set +u
|
|
|
|
}
|