lean4-htt/nix/leanpkg-dev.in
2021-04-05 10:50:21 +02:00

20 lines
674 B
Bash

#!@bash@/bin/bash
set -euo pipefail
[[ $# -gt 0 && "$1" == print-paths && ( -f flake.nix || -d Lean && -f ../flake.nix || ! -f leanpkg.toml ) ]] || exec @leanpkg@/bin/leanpkg "$@"
shift
deps="$@"
root=.
# fall back to initial package if not in package
[[ ! -f "$root/flake.nix" ]] && root="@srcRoot@"
target="$root#print-paths"
args=()
# HACK: use stage 0 instead of 1 inside Lean's own `src/`
[[ -d Lean && -f ../flake.nix ]] && target="@srcTarget@print-paths" && args=@srcArgs@
for dep in $deps; do
target="$target.\"$dep\""
done
# -v only has "built ...", but "-vv" is a bit too verbose
echo "Building dependencies..." >&2
@nix@/bin/nix run "$target" ${args[*]} -v