forked from leanprover/lean4
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nix: Avoid adding search path symlinks to the nix store
This fixes leanprover#2508
- Loading branch information
Showing
3 changed files
with
51 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Given a target directory and one (or more) `lean-deps.txt` file, as built by buildLeanPackage, | ||
# recursively traverses it and symlinks the contents into one big directory. | ||
|
||
set -e | ||
|
||
# first argument: directory to create | ||
dest="$1" | ||
shift | ||
|
||
# remaining arguments: lean-dep.txt files | ||
# read their lines into the todo array | ||
declare -a todo | ||
for file in "$@" | ||
do | ||
readarray -t -O ${#todo[@]} todo < "$file" | ||
done | ||
|
||
mkdir "$dest" | ||
|
||
# simple work-list algorithm | ||
declare -A seen | ||
while [ ${#todo[@]} -gt 0 ] | ||
do | ||
n=$((${#todo[@]}-1)) | ||
dir="${todo[n]}" | ||
unset "todo[$n]" | ||
if ! [[ -v "seen[$dir]" ]] | ||
then | ||
seen[$dir]="seen" | ||
cp -rs --no-preserve=mode "$dir"/. "$dest" | ||
rm "$dest"/lean-deps.txt | ||
readarray -t -O ${#todo[@]} todo < "$dir"/lean-deps.txt | ||
fi | ||
done |