diff --git a/pkgs/development/lisp-modules/clwrapper/cl-wrapper.sh b/pkgs/development/lisp-modules/clwrapper/cl-wrapper.sh index 05376c1e9a3c..5bf375a4eff5 100755 --- a/pkgs/development/lisp-modules/clwrapper/cl-wrapper.sh +++ b/pkgs/development/lisp-modules/clwrapper/cl-wrapper.sh @@ -19,16 +19,19 @@ case "$NIX_LISP" in sbcl) NIX_LISP_LOAD_FILE="--load" NIX_LISP_EXEC_CODE="--eval" + NIX_LISP_QUIT="(quit)" NIX_LISP_FINAL_PARAMETERS= ;; ecl) NIX_LISP_LOAD_FILE="-load" NIX_LISP_EXEC_CODE="-eval" + NIX_LISP_QUIT="(quit)" NIX_LISP_FINAL_PARAMETERS= ;; clisp) NIX_LISP_LOAD_FILE="-c -l" NIX_LISP_EXEC_CODE="-x" + NIX_LISP_QUIT="(quit)" NIX_LISP_FINAL_PARAMETERS="-repl" ;; esac diff --git a/pkgs/development/lisp-modules/clwrapper/common-lisp.sh b/pkgs/development/lisp-modules/clwrapper/common-lisp.sh index a4634152db71..43349cc7f8a2 100755 --- a/pkgs/development/lisp-modules/clwrapper/common-lisp.sh +++ b/pkgs/development/lisp-modules/clwrapper/common-lisp.sh @@ -1,3 +1,3 @@ #! /bin/sh -"$(dirname "$0")"/cl-wrapper.sh "${NIX_LISP_COMMAND:-$(ls "@lisp@/bin"/* | head -n 1)}" "$@" +source "@out@"/bin/cl-wrapper.sh "${NIX_LISP_COMMAND:-$(ls "@lisp@/bin"/* | head -n 1)}" "$@" diff --git a/pkgs/development/lisp-modules/lisp-packages.nix b/pkgs/development/lisp-modules/lisp-packages.nix index 36e0b34e005b..8e3c56d49a84 100644 --- a/pkgs/development/lisp-modules/lisp-packages.nix +++ b/pkgs/development/lisp-modules/lisp-packages.nix @@ -575,5 +575,32 @@ let lispPackages = rec { }; }; + quicklisp = buildLispPackage rec { + baseName = "quicklisp"; + version = "2016-01-21"; + description = "The Common Lisp package manager"; + deps = []; + src = pkgs.fetchgit { + url = "https://github.com/quicklisp/quicklisp-client/"; + rev = "refs/tags/version-${version}"; + sha256 = "0a6zjsd5c8zg2x26lc027538xfl182xvg7ps81pyvi4k5qd42xhd"; + }; + overrides = x: rec { + inherit clwrapper; + quicklispdist = pkgs.fetchurl { + # Will usually be replaced with a fresh version anyway, but needs to be + # a valid distinfo.txt + url = "http://beta.quicklisp.org/dist/quicklisp/2016-03-18/distinfo.txt"; + sha256 = "13mvign4rsicfvg3vs3vj1qcjvj2m1aqhq93ck0sgizxfcj5167m"; + }; + buildPhase = '' true; ''; + postInstall = '' + substituteAll ${./quicklisp.sh} "$out"/bin/quicklisp + chmod a+x "$out"/bin/quicklisp + cp "${quicklispdist}" "$out/lib/common-lisp/quicklisp/quicklisp-distinfo.txt" + ''; + }; + }; + }; in lispPackages diff --git a/pkgs/development/lisp-modules/quicklisp.sh b/pkgs/development/lisp-modules/quicklisp.sh new file mode 100644 index 000000000000..30d14419461e --- /dev/null +++ b/pkgs/development/lisp-modules/quicklisp.sh @@ -0,0 +1,85 @@ +#! /usr/bin/env bash + +op= +end_param= +args=() +cmd_args=() + +while let "$#"; do + if test -n "$end_param" || test "$1" = "${1#--}"; then + if test -n "$op"; then + args[${#args[@]}]="$1"; + else + op="$1" + fi + shift + else + case "$1" in + --) + end_param=1; shift; + ;; + --quicklisp-dir) + NIX_QUICKLISP_DIR="$2"; + shift; shift; + ;; + --help) + echo "Operation: init, run, update, install {system-name}" + exit 0; + ;; + *) + echo "Unknown parameter [$1]" >&2 + exit 2; + ;; + esac + fi +done + +NIX_QUICKLISP_DIR="${NIX_QUICKLISP_DIR:-${HOME}/quicklisp}" + +case "$op" in + '') echo "Specify an operation: init, install, run, update" + ;; + install) + NIX_LISP_SKIP_CODE=1 source "@clwrapper@/bin/common-lisp.sh"; + + cmd_args[${#cmd_args[@]}]="$NIX_LISP_EXEC_CODE" + cmd_args[${#cmd_args[@]}]="(load \"$NIX_QUICKLISP_DIR/setup.lisp\")" + for i in "${args[@]}"; do + cmd_args[${#cmd_args[@]}]="$NIX_LISP_EXEC_CODE" + cmd_args[${#cmd_args[@]}]="(ql:quickload :$i)" + done + cmd_args[${#cmd_args[@]}]="$NIX_LISP_EXEC_CODE" + cmd_args[${#cmd_args[@]}]="$NIX_LISP_QUIT" + + "@clwrapper@/bin/common-lisp.sh" "${cmd_args[@]}" + ;; + update) + NIX_LISP_SKIP_CODE=1 source "@clwrapper@/bin/common-lisp.sh" + + ln -sfT "@out@/lib/common-lisp/quicklisp/asdf.lisp" "$NIX_QUICKLISP_DIR/asdf.lisp" + cp -f "@out@/lib/common-lisp/quicklisp/setup.lisp" "$NIX_QUICKLISP_DIR/setup.lisp" + + if test -d "$NIX_QUICKLISP_DIR/quicklisp"; then + mv "$NIX_QUICKLISP_DIR/quicklisp"{,-old-$(date +%Y%m%d-%H%M%S)} + fi + + ln -sfT "@out@/lib/common-lisp/quicklisp/quicklisp" "$NIX_QUICKLISP_DIR/quicklisp" + + "@clwrapper@/bin/common-lisp.sh" "$NIX_LISP_EXEC_CODE" \ + "(load \"$NIX_QUICKLISP_DIR/setup.lisp\")" "$NIX_LISP_EXEC_CODE" \ + "(ql:update-all-dists)" "$NIX_LISP_EXEC_CODE" "$NIX_LISP_QUIT" + ;; + init) + mkdir -p "$NIX_QUICKLISP_DIR"/{dists/quicklisp,tmp,local-projects} + echo 1 > "$NIX_QUICKLISP_DIR/dists/quicklisp/enabled.txt" + cp -f "@out@/lib/common-lisp/quicklisp/quicklisp-distinfo.txt" \ + "$NIX_QUICKLISP_DIR/dists/quicklisp/distinfo.txt" + + NIX_QUICKLISP_DIR="$NIX_QUICKLISP_DIR" "$0" update + ;; + run) + NIX_LISP_SKIP_CODE=1 source "@clwrapper@/bin/common-lisp.sh" + "@clwrapper@/bin/common-lisp.sh" "$NIX_LISP_EXEC_CODE" \ + "(load \"$NIX_QUICKLISP_DIR/setup.lisp\")" "${args[@]}" + ;; +esac