Adding a facility to generate Lisp module definitions from QuickLisp; no sane update facility yet; adding Esrap-PEG as a test

This commit is contained in:
Michael Raskin 2013-10-29 10:56:33 +04:00
parent a976962d6c
commit 22ddf66b54
8 changed files with 196 additions and 1 deletions

View file

@ -7,3 +7,8 @@ SF_redirect () {
SF_version_dir () {
version_link 'http://sourceforge.net/.+/[0-9.]+/$'
}
GH_latest () {
prefetch_command_rel ../fetchgit/nix-prefetch-git
rev "$(curl "$CURRENT_URL/commits" | grep /commit/ | head -n 1 | xargs basename )"
}

View file

@ -3,6 +3,8 @@
own_dir="$(cd "$(dirname "$0")"; pwd)"
CURRENT_URL=
CURRENT_REV=
PREFETCH_COMMAND=
NEED_TO_CHOOSE_URL=1
url () {
@ -118,13 +120,25 @@ ensure_choice () {
}
}
rev () {
CURRENT_REV="$1"
}
prefetch_command () {
PREFETCH_COMMAND="$1"
}
prefetch_command_rel () {
PREFETCH_COMMAND="$(dirname "$0")/$1"
}
ensure_hash () {
echo "Ensuring hash. CURRENT_HASH: $CURRENT_HASH" >&2
[ -z "$CURRENT_HASH" ] && hash
}
hash () {
CURRENT_HASH="$(nix-prefetch-url "$CURRENT_URL")"
CURRENT_HASH="$(${PREFETCH_COMMAND:-nix-prefetch-url} "$CURRENT_URL" $CURRENT_REV)"
echo "CURRENT_HASH: $CURRENT_HASH" >&2
}
@ -172,6 +186,7 @@ do_write_expression () {
echo "${1} name=\"\${baseName}-\${version}\";"
echo "${1} hash=\"$CURRENT_HASH\";"
echo "${1} url=\"$CURRENT_URL\";"
[ -n "$CURRENT_REV" ] && echo "${1} rev=\"$CURRENT_REV\";"
echo "${1} sha256=\"$CURRENT_HASH\";"
echo "$2"
}

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -45,5 +45,59 @@ let lispPackages = rec {
};
stumpwm = callPackage ./stumpwm {};
alexandria = buildLispPackage rec {
baseName = "alexandria";
version = "git-20131029";
description = "Alexandria is a collection of portable public domain utilities.";
deps = [];
src = pkgs.fetchgit {
url = "git://common-lisp.net/projects/alexandria/alexandria.git";
sha256 = "1d981a243f9d4d3c9fd86cc47698050507ff615b87b9a710449abdb4234e501b";
rev = ''2b1eb4067fb34bc501e527de75d09166a8ba9ceb'';
};
};
esrap-peg = buildLispPackage rec {
baseName = "esrap-peg";
version = "git-20131029";
description = "A wrapper around Esrap to allow generating Esrap grammars from PEG definitions";
deps = [alexandria cl-unification esrap iterate];
src = pkgs.fetchgit {
url = "https://github.com/fb08af68/esrap-peg";
sha256 = "48e616a697aca95e90e55052fdc9a7f96bf29b3208b1b4012fcd3189c2eceeb1";
rev = ''1f2f21e32e618f71ed664cdc5e7005f8b6b0f7c8'';
};
};
cl-unification = buildLispPackage rec {
baseName = "cl-unification";
version = "cvs-2013-10-28";
description = "";
deps = [];
src = pkgs.fetchcvs {
sha256 = "a574b7f9615232366e3e5e7ee400d60dbff23f6d0e1def5a3c77aafdfd786e6a";
date = ''2013-10-28'';
module = ''cl-unification'';
cvsRoot = '':pserver:anonymous:anonymous@common-lisp.net:/project/cl-unification/cvsroot'';
};
};
esrap = buildLispPackage rec {
baseName = "esrap";
version = "git-20131029";
description = "A Packrat / Parsing Grammar / TDPL parser for Common Lisp.";
deps = [alexandria];
src = pkgs.fetchgit {
url = "https://github.com/scymtym/esrap";
sha256 = "c56616ac01be0f69e72902f9fd830a8af2c2fa9018b66747a5da3988ae38817f";
rev = ''c71933b84e220f21e8a509ec26afe3e3871e2e26'';
};
};
};
in lispPackages