summary refs log tree commit diff
path: root/pkgs/development/lisp-modules/clwrapper/default.nix
blob: 3cb8219e68742d0ee59419d9ca234170ca394326 (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
{stdenv, asdf, which, bash, lisp ? null}:
stdenv.mkDerivation {
  name = "cl-wrapper-script";

  buildPhase="";

  installPhase=''
    mkdir -p "$out"/bin
    export head="$(which head)"
    export ls="$(which ls)"
    substituteAll ${./common-lisp.sh} "$out"/bin/common-lisp.sh
    substituteAll "${./build-with-lisp.sh}" "$out/bin/build-with-lisp.sh"
    substituteAll "${./cl-wrapper.sh}" "$out/bin/cl-wrapper.sh"
    patchShebangs "$out/bin"
    chmod a+x "$out"/bin/*

    substituteAll "${./setup-hook.sh}" "setup-hook-parsed"
    addEnvHooks(){ true; };
    source setup-hook-parsed
    setLisp "${lisp}"
    echo "$NIX_LISP"

    mkdir -p "$out/lib/common-lisp/"
    cp -r "${asdf}/lib/common-lisp"/* "$out/lib/common-lisp/"
    chmod u+rw -R "$out/lib/common-lisp/"

    NIX_LISP_PRELAUNCH_HOOK='
      NIX_LISP_FASL_TYPE=lisp
      nix_lisp_run_single_form "(progn
        (uiop/lisp-build:compile-file* \"'"$out"'/lib/common-lisp/asdf/build/asdf.lisp\")
        (asdf:load-system :uiop :force :all)
        (asdf:load-system :asdf :force :all)
        (ignore-errors (asdf:load-system :uiop/version :force :all))
      )"' \
      "$out/bin/common-lisp.sh"
  '';

  buildInputs = [which];

  inherit asdf lisp bash;
  stdenv_shell = stdenv.shell;

  setupHook = ./setup-hook.sh;

  phases="installPhase fixupPhase";

  ASDF_OUTPUT_TRANSLATIONS="${builtins.storeDir}/:${builtins.storeDir}";

  passthru = {
    inherit lisp;
  };

  meta = {
    description = ''Script used to wrap Common Lisp implementations'';
    maintainers = [stdenv.lib.maintainers.raskin];
  };
}