summary refs log tree commit diff
path: root/pkgs/development/lisp-modules/from-quicklisp/barebones-quicklisp-expression.sh
blob: 61c00eb92ae855c64addd265a2f792a6e4c792c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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