about summary refs log tree commit diff
path: root/pkgs/development/lisp-modules/from-quicklisp
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2013-10-29 10:56:33 +0400
committerMichael Raskin <7c6f434c@mail.ru>2013-10-29 10:56:33 +0400
commit22ddf66b54396f865ae1c1df6a366640039c20c6 (patch)
treeb16622d756ba5b91f3c5a568822e72fb75384e4a /pkgs/development/lisp-modules/from-quicklisp
parenta976962d6cb87ffb946956fe58a5dfd5742f769e (diff)
downloadnixlib-22ddf66b54396f865ae1c1df6a366640039c20c6.tar
nixlib-22ddf66b54396f865ae1c1df6a366640039c20c6.tar.gz
nixlib-22ddf66b54396f865ae1c1df6a366640039c20c6.tar.bz2
nixlib-22ddf66b54396f865ae1c1df6a366640039c20c6.tar.lz
nixlib-22ddf66b54396f865ae1c1df6a366640039c20c6.tar.xz
nixlib-22ddf66b54396f865ae1c1df6a366640039c20c6.tar.zst
nixlib-22ddf66b54396f865ae1c1df6a366640039c20c6.zip
Adding a facility to generate Lisp module definitions from QuickLisp; no sane update facility yet; adding Esrap-PEG as a test
Diffstat (limited to 'pkgs/development/lisp-modules/from-quicklisp')
-rwxr-xr-xpkgs/development/lisp-modules/from-quicklisp/asdf-description.sh16
-rwxr-xr-xpkgs/development/lisp-modules/from-quicklisp/barebones-quicklisp-expression.sh78
-rwxr-xr-xpkgs/development/lisp-modules/from-quicklisp/quicklisp-beta-env.sh16
-rwxr-xr-xpkgs/development/lisp-modules/from-quicklisp/quicklisp-dependencies.sh11
-rw-r--r--pkgs/development/lisp-modules/from-quicklisp/tmp.nix0
5 files changed, 121 insertions, 0 deletions
diff --git a/pkgs/development/lisp-modules/from-quicklisp/asdf-description.sh b/pkgs/development/lisp-modules/from-quicklisp/asdf-description.sh
new file mode 100755
index 000000000000..6c240d15c76e
--- /dev/null
+++ b/pkgs/development/lisp-modules/from-quicklisp/asdf-description.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+[ -z "$NIX_QUICKLISP_DIR" ] && {
+  export NIX_QUICKLISP_DIR="$(mktemp -d --tmpdir nix-quicklisp.XXXXXX)"
+}
+
+[ -f "$NIX_QUICKLISP_DIR/setup.lisp" ] || {
+  "$(dirname "$0")/quicklisp-beta-env.sh" "$NIX_QUICKLISP_DIR" &> /dev/null < /dev/null
+}
+
+name="$1"
+
+sbcl --noinform --load "$NIX_QUICKLISP_DIR"/setup.lisp --eval "(ql:quickload :$name)" \
+	--eval "(format t \"~a~%\" (or (asdf::system-description (asdf::find-system \"$name\")) \"\"))" \
+	--eval '(quit)' --script |
+    tee /dev/stderr | tail -n 1
diff --git a/pkgs/development/lisp-modules/from-quicklisp/barebones-quicklisp-expression.sh b/pkgs/development/lisp-modules/from-quicklisp/barebones-quicklisp-expression.sh
new file mode 100755
index 000000000000..61c00eb92ae8
--- /dev/null
+++ b/pkgs/development/lisp-modules/from-quicklisp/barebones-quicklisp-expression.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+
+name="$1"
+
+nix-instantiate "$(dirname "$0")"/../../../../ -A "lispPackages.$name" > /dev/null && exit
+[ "$NIX_LISP_PACKAGES_DEFINED" != "${NIX_LISP_PACKAGES_DEFINED/$name/@@}" ] && exit
+
+NIX_LISP_PACKAGES_DEFINED="$NIX_LISP_PACKAGES_DEFINED $1 "
+
+[ -z "$NIX_QUICKLISP_DIR" ] && {
+  export NIX_QUICKLISP_DIR="$(mktemp -d --tmpdir nix-quicklisp.XXXXXX)"
+}
+
+[ -f "$NIX_QUICKLISP_DIR/setup.lisp" ] || {
+  "$(dirname "$0")/quicklisp-beta-env.sh" "$NIX_QUICKLISP_DIR" &> /dev/null < /dev/null
+}
+
+description="$("$(dirname "$0")/asdf-description.sh" "$name")"
+[ -z "$description" ] && {
+  description="$(curl -L https://github.com/quicklisp/quicklisp-projects/raw/master/"$name"/description.txt)"
+  [ "$(echo "$description" | wc -l)" -gt 10 ] && description=""
+}
+
+dependencies="$("$(dirname "$0")/quicklisp-dependencies.sh" "$name" | xargs)"
+ql_src="$(curl -L https://github.com/quicklisp/quicklisp-projects/raw/master/"$name"/source.txt)"
+ql_src_type="${ql_src%% *}"
+url="${ql_src##* }"
+
+[ "$ql_src_type" = git ] && {
+  fetcher="pkgs.fetchgit"
+  [ "${url#git://github.com/}" != "$url" ] && {
+    url="${url/git:/https:}"
+    url="${url%.git}"
+    rev=$("$(dirname "$0")/../../../build-support/upstream-updater/urls-from-page.sh" "$url/commits" | grep /commit/ | head -n 1 | xargs basename)
+    hash=$("$(dirname "$0")/../../../build-support/fetchgit/nix-prefetch-git" "$url" "$rev")
+    version="git-$(date +%Y%m%d)";
+  }
+  [ "${url#git://common-lisp.net/}" != "$url" ] && {
+    http_repo_url="$url"
+    http_repo_url="${http_repo_url/git:/http:}"
+    http_repo_url="${http_repo_url/\/projects\// /r/projects/}"
+    http_repo_head="$http_repo_url/refs/heads/master"
+    echo "$http_repo_head" >&2
+    rev=$(curl -L "$http_repo_head");
+    hash=$("$(dirname "$0")/../../../build-support/fetchgit/nix-prefetch-git" "$url" "$rev")
+    version="git-$(date +%Y%m%d)";
+  }
+}
+
+[ "$ql_src_type" = cvs ] && {
+  fetcher="pkgs.fetchcvs"
+  date="$(date -d yesterday +%Y-%m-%d)"
+  version="cvs-$date"
+  module="${module:-$name}"
+  hash=$(USE_DATE=1 "$(dirname "$0")/../../../build-support/fetchcvs/nix-prefetch-cvs" "$url" "$module" "$date")
+  cvsRoot="$url"
+  unset url
+}
+
+cat << EOF
+
+  $name = buildLispPackage rec {
+    baseName = "$name";
+    version = "${version:-\${Set me //}";
+    description = "$description";
+    deps = [$dependencies];
+    src = ${fetcher:-pkgs.fetchurl} {
+      ${url:+url = ''$url'';}
+      sha256 = "${hash:-0000000000000000000000000000000000000000000000000000000000000000}";
+      ${rev:+rev = ''$rev'';}
+      ${date:+date = ''$date'';}
+      ${module:+module = ''$module'';}
+      ${cvsRoot:+cvsRoot = ''$cvsRoot'';}
+    };
+  };
+EOF
+
+for i in $dependencies; do "$0" "$i"; done
diff --git a/pkgs/development/lisp-modules/from-quicklisp/quicklisp-beta-env.sh b/pkgs/development/lisp-modules/from-quicklisp/quicklisp-beta-env.sh
new file mode 100755
index 000000000000..32fbbe4bb2bc
--- /dev/null
+++ b/pkgs/development/lisp-modules/from-quicklisp/quicklisp-beta-env.sh
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+WORK_DIR=$(mktemp -d "/tmp/ql-venv-XXXXXX")
+mkdir -p "${1:-.}"
+TARGET="$(cd "${1:-.}"; pwd)"
+
+curl http://beta.quicklisp.org/quicklisp.lisp > "$WORK_DIR/ql.lisp"
+
+sbcl --noinform \
+     --load "$WORK_DIR/ql.lisp" \
+     --eval "(quicklisp-quickstart:install :path \"$TARGET/\")" \
+     --eval "(cl-user::quit)" \
+     --script
+
+
+rm -rf "$WORK_DIR"
diff --git a/pkgs/development/lisp-modules/from-quicklisp/quicklisp-dependencies.sh b/pkgs/development/lisp-modules/from-quicklisp/quicklisp-dependencies.sh
new file mode 100755
index 000000000000..24efbdd3e16e
--- /dev/null
+++ b/pkgs/development/lisp-modules/from-quicklisp/quicklisp-dependencies.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+[ -z "$NIX_QUICKLISP_DIR" ] && {
+  export NIX_QUICKLISP_DIR="$(mktemp -d --tmpdir nix-quicklisp.XXXXXX)"
+}
+
+[ -f "$NIX_QUICKLISP_DIR/setup.lisp" ] || {
+  "$(dirname "$0")/quicklisp-beta-env.sh" "$NIX_QUICKLISP_DIR" &> /dev/null < /dev/null
+}
+
+sbcl --noinform --eval "(with-output-to-string (*standard-output*) (load \"$NIX_QUICKLISP_DIR/setup.lisp\"))" --eval "(with-output-to-string (*standard-output*) (with-output-to-string (*error-output*) (with-output-to-string (*trace-output*) (ql:quickload :$1))))" --eval "(format t \"~{~a~%~}\" (mapcar 'ql::name (mapcar 'car (cdr (ql::dependency-tree \"$1\")))))" --eval '(quit)' --script
diff --git a/pkgs/development/lisp-modules/from-quicklisp/tmp.nix b/pkgs/development/lisp-modules/from-quicklisp/tmp.nix
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/pkgs/development/lisp-modules/from-quicklisp/tmp.nix