2 # Part of NixPkgs package collection
3 # This script can be used at your option under the same license as NixPkgs or
4 # under MIT/X11 license
6 eval "$NIX_LISP_PREHOOK"
11 if [ -z "$NIX_LISP" ]; then
12 while [ -h "${NIX_LISP_COMMAND}" ]; do
13 NIX_LISP_COMMAND
="$(readlink -n "${NIX_LISP_COMMAND}")"
15 NIX_LISP
="${NIX_LISP_COMMAND##*/}"
18 export NIX_LISP NIX_LISP_LOAD_FILE NIX_LISP_EXEC_CODE NIX_LISP_COMMAND NIX_LISP_FINAL_PARAMETERS
20 test -n "$NIX_LISP_LD_LIBRARY_PATH" &&
21 export LD_LIBRARY_PATH
="$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}$NIX_LISP_LD_LIBRARY_PATH"
23 declare -a NIX_LISP_FINAL_PARAMETERS
;
27 NIX_LISP_LOAD_FILE
="--load"
28 NIX_LISP_EXEC_CODE
="--eval"
29 NIX_LISP_QUIT
="(quit)"
30 NIX_LISP_NODEBUG
='--non-interactive'
31 NIX_LISP_FINAL_PARAMETERS
=
32 NIX_LISP_FASL_TYPE
="fasl"
35 NIX_LISP_LOAD_FILE
="-load"
36 NIX_LISP_EXEC_CODE
="-eval"
37 NIX_LISP_QUIT
="(quit)"
38 NIX_LISP_NODEBUG
='--nodebug'
39 NIX_LISP_FINAL_PARAMETERS
=
40 NIX_LISP_FASL_TYPE
="fas"
43 NIX_LISP_LOAD_FILE
="-c -l"
44 NIX_LISP_EXEC_CODE
="-x"
45 NIX_LISP_QUIT
="(quit)"
46 NIX_LISP_NODEBUG
='-on-error exit'
47 NIX_LISP_FINAL_PARAMETERS
="-repl"
48 NIX_LISP_FASL_TYPE
="fas"
51 NIX_LISP_LOAD_FILE
="-l"
52 NIX_LISP_EXEC_CODE
="-e"
53 NIX_LISP_QUIT
="(quit)"
55 NIX_LISP_FINAL_PARAMETERS
=
56 NIX_LISP_FASL_TYPE
="lx64fsl"
59 NIX_LISP_LOAD_FILE
="-l"
60 NIX_LISP_EXEC_CODE
="-e"
61 NIX_LISP_QUIT
="(quit)"
63 NIX_LISP_FINAL_PARAMETERS
=
64 NIX_LISP_FASL_TYPE
="lx32fsl"
67 NIX_LISP_LOAD_FILE
="--load"
68 NIX_LISP_EXEC_CODE
="--eval"
69 NIX_LISP_QUIT
="(quit)"
71 NIX_LISP_FINAL_PARAMETERS
=
72 NIX_LISP_FASL_TYPE
="abcl"
76 NIX_LISP_ASDF_REGISTRY_CODE
="
78 (setf asdf:*source-registry-parameter*
80 $(for p in $NIX_LISP_ASDF_PATHS; do
83 :inherit-configuration))
84 (asdf:initialize-source-registry)
88 NIX_LISP_ASDF
="${NIX_LISP_ASDF:-@out@}"
90 nix_lisp_run_single_form
(){
91 NIX_LISP_FINAL_PARAMETERS
=("$NIX_LISP_EXEC_CODE" "$1"
92 "$NIX_LISP_EXEC_CODE" "$NIX_LISP_QUIT" $NIX_LISP_NODEBUG)
95 nix_lisp_build_system
(){
96 NIX_LISP_FINAL_PARAMETERS
=(
97 "$NIX_LISP_EXEC_CODE" "(progn
98 (asdf:load-system :$1)
99 (loop for s in (list $(for i in $3; do echo ":$i"; done)) do (asdf:load-system s)))"
100 "$NIX_LISP_EXEC_CODE" "(progn
101 (setf (asdf/system:component-entry-point (asdf:find-system :$1)) ${2:-nil})
102 #+cffi(setf cffi:*foreign-library-directories*
103 (cffi::explode-path-environment-variable \"NIX_LISP_LD_LIBRARY_PATH\"))
105 with libpath := (uiop:split-string (uiop:getenv \"NIX_LISP_LD_LIBRARY_PATH\")
107 for l in sb-alien::*shared-objects*
108 for ns := (sb-alien::shared-object-namestring l)
109 do (format *error-output* \"Searching alien object ~s in ~s~%\"
111 do (and (> (length ns) 0) (not (equal (elt ns 0) \"/\"))
113 ((prefix (find-if (lambda (s) (probe-file (format nil \"~a/~a\" s ns))) libpath))
114 (fullpath (and prefix (format nil \"~a/~a\" prefix ns))))
116 (format *error-output* \"Found: ~s~%\" fullpath)
118 (sb-alien::shared-object-namestring l) fullpath
119 (sb-alien::shared-object-pathname l) (probe-file fullpath)))))
122 (asdf:perform (quote asdf:program-op) :$1)
126 eval "$NIX_LISP_PRELAUNCH_HOOK"
128 if [ -z "$NIX_LISP_SKIP_CODE" ]; then
129 "$NIX_LISP_COMMAND" $NIX_LISP_EARLY_OPTIONS \
130 $NIX_LISP_EXEC_CODE "${NIX_LISP_ASDF_LOAD:-"(load \"$NIX_LISP_ASDF/lib/common-lisp/asdf/build/asdf.$NIX_LISP_FASL_TYPE\")"}" \
131 $NIX_LISP_EXEC_CODE "$NIX_LISP_ASDF_REGISTRY_CODE" \
132 ${NIX_LISP_FINAL_PARAMETERS[*]:+"${NIX_LISP_FINAL_PARAMETERS[@]}"} \