fix: Nix: leanpkg outside flake

This commit is contained in:
Sebastian Ullrich 2021-04-05 10:50:21 +02:00
parent 6dc3e55c54
commit e10cf4cf33
2 changed files with 6 additions and 3 deletions

View file

@ -181,6 +181,7 @@ in rec {
dir = "bin";
src = ./leanpkg-dev.in;
isExecutable = true;
srcRoot = fullSrc; # use root flake.nix in case of Lean repo
inherit bash nix srcTarget srcArgs;
leanpkg = lean;
};

View file

@ -2,11 +2,13 @@
set -euo pipefail
[[ $# -gt 0 && "$1" == print-paths && ( -f flake.nix || -d Lean && -f ../flake.nix ) ]] || exec @leanpkg@/bin/leanpkg "$@"
[[ $# -gt 0 && "$1" == print-paths && ( -f flake.nix || -d Lean && -f ../flake.nix || ! -f leanpkg.toml ) ]] || exec @leanpkg@/bin/leanpkg "$@"
shift
deps="$@"
target=".#print-paths"
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@