pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / development / lisp-modules / setup-hook.sh
blob6beb96231b216640a4d5e7bfc1842fde24ad4eba
1 # This setup hook adds every propagated lisp system to CL_SOURCE_REGISTRY
3 buildAsdfPath () {
4 declare -A seen=()
5 for dep in $propagatedBuildInputs; do
6 _addToAsdfPath $dep
7 done
10 addFileToSearchPathWithCustomDelimiter() {
11 local delimiter="$1"
12 local varName="$2"
13 local file="$3"
14 if [[ -f "$file" && "${!varName:+${delimiter}${!varName}${delimiter}}" \
15 != *"${delimiter}${file}${delimiter}"* ]]; then
16 export "${varName}=${!varName:+${!varName}${delimiter}}${file}"
20 addFileToSearchPath() {
21 addFileToSearchPathWithCustomDelimiter ":" "$@"
24 _addToAsdfPath () {
25 local dep="$1"
26 if [ -v seen[$dep] ]; then
27 return
28 else
29 seen[$dep]=1
30 local path="$dep"
32 # FIXME slow
34 while read file; do
35 case "${file##*.}" in
36 jar) addFileToSearchPath "CLASSPATH" "$file" ;;
37 class) addToSearchPath "CLASSPATH" "${file%/*}" ;;
38 so) addToSearchPath "LD_LIBRARY_PATH" "${file%/*}" ;;
39 dylib) addToSearchPath "DYLD_LIBRARY_PATH" "${file%/*}" ;;
40 asd) addToSearchPath "CL_SOURCE_REGISTRY" "$path//" ;;
41 esac
42 done < <(find "$path" -type f,l -name '*.asd' -o -name '*.jar' \
43 -o -name '*.class' -o -name '*.so' -o -name '*.dylib')
45 local prop="$dep/nix-support/propagated-build-inputs"
47 if [ -e "$prop" ]; then
48 local new_system
49 for new_system in $(cat $prop); do
50 _addToAsdfPath "$new_system"
51 done
56 # addEnvHooks "$targetOffset" buildAsdfPath