Adding a Common Lisp wrapper.

Features:
  + configurable via environment variables
  + can skip the actual launching of the lisp implementation (source it
  with NIX_LISP_SKIP_CODE=1 to get all the settings)
  + currently supports SBCL, CLisp, ECL
  + determines lisp implementation from NIX_LISP_COMMAND variable or
  from buildInputs
  + sets ASDF search path for packages using buildInputs
This commit is contained in:
Michael Raskin 2013-10-13 10:45:07 +04:00
parent f1dd61d353
commit d44439d03e
5 changed files with 110 additions and 0 deletions

View File

@ -0,0 +1,44 @@
#! /bin/sh
# Part of NixPkgs package collection
# This script can be used at your option under the same license as NixPkgs or
# under MIT/X11 license
eval "$NIX_LISP_PREHOOK"
NIX_LISP_COMMAND="$1"
shift
[ -z "$NIX_LISP" ] && NIX_LISP="${NIX_LISP_COMMAND##*/}"
export NIX_LISP NIX_LISP_LOAD_FILE NIX_LISP_EXEC_CODE NIX_LISP_COMMAND NIX_LISP_FINAL_PARAMETERS
case "$NIX_LISP" in
sbcl)
NIX_LISP_LOAD_FILE="--load"
NIX_LISP_EXEC_CODE="--eval"
NIX_LISP_FINAL_PARAMETERS=
;;
ecl)
NIX_LISP_LOAD_FILE="-load"
NIX_LISP_EXEC_CODE="-eval"
NIX_LISP_FINAL_PARAMETERS=
;;
clisp)
NIX_LISP_LOAD_FILE="-c -l"
NIX_LISP_EXEC_CODE="-x"
NIX_LISP_FINAL_PARAMETERS="-repl"
;;
esac
NIX_LISP_ASDF_REGISTRY_CODE="
(progn
(setf asdf:*default-source-registries* '(asdf/source-registry:environment-source-registry))
(asdf:initialize-source-registry)
)
"
[ -z "$NIX_LISP_SKIP_CODE" ] && "$NIX_LISP_COMMAND" $NIX_LISP_EARLY_OPTIONS \
$NIX_LISP_EXEC_CODE "(load \"$NIX_LISP_ASDF/lib/common-lisp/asdf/build/asdf.lisp\")" \
$NIX_LISP_EXEC_CODE "$NIX_LISP_ASDF_REGISTRY_CODE" \
$NIX_LISP_FINAL_PARAMETERS \
"$@"

View File

@ -0,0 +1,3 @@
#! /bin/sh
"$(dirname "$0")"/cl-wrapper.sh "${NIX_LISP_COMMAND:-sbcl}" "$@"

View File

@ -0,0 +1,28 @@
{stdenv, fetchurl, asdf, lisp ? null}:
stdenv.mkDerivation {
name = "cl-wrapper-script";
buildPhase="";
installPhase=''
mkdir -p "$out"/bin
cp ${./cl-wrapper.sh} "$out"/bin/cl-wrapper.sh
cp ${./common-lisp.sh} "$out"/bin/common-lisp.sh
chmod a+x "$out"/bin/*
'';
inherit asdf lisp;
setupHook = ./setup-hook.sh;
phases="installPhase fixupPhase";
passthru = {
inherit lisp;
};
meta = {
description = ''Script used to wrap Common Lisp implementations'';
maintainers = [stdenv.lib.maintainers.raskin];
};
}

View File

@ -0,0 +1,33 @@
NIX_LISP_ASDF="@asdf@"
CL_SOURCE_REGISTRY="@asdf@/lib/common-lisp/asdf/:@asdf@/lib/common-lisp/asdf/uiop/"
addASDFPaths () {
for j in "$1"/lib/common-lisp/*; do
if [ -d "$j" ]; then
CL_SOURCE_REGISTRY="$CL_SOURCE_REGISTRY:$j/"
fi
done
}
setLisp () {
if [ -z "$NIX_LISP_COMMAND" ]; then
for j in "$1"/bin/*; do
case "$(basename "$j")" in
sbcl) NIX_LISP_COMMAND="$j" ;;
ecl) NIX_LISP_COMMAND="$j" ;;
clisp) NIX_LISP_COMMAND="$j" ;;
esac
done
fi
if [ -z "$NIX_LISP" ]; then
NIX_LISP="${NIX_LISP_COMMAND##*/}"
fi
}
export NIX_LISP_COMMAND NIX_LISP CL_SOURCE_REGISTRY NIX_LISP_ASDF
envHooks=(envHooks[@] addASDFPaths setLisp)
mkdir -p "$HOME"/.cache/common-lisp || HOME="$TMP/.temp-$USER-home"
mkdir -p "$HOME"/.cache/common-lisp

View File

@ -5881,6 +5881,8 @@ let
### DEVELOPMENT / LISP MODULES
asdf = callPackage ../development/lisp-modules/asdf {};
clwrapperFunction = callPackage ../development/lisp-modules/clwrapper;
wrapLisp = lisp: clwrapperFunction {lisp=lisp;};
### DEVELOPMENT / PERL MODULES