summaryrefslogtreecommitdiff
path: root/pkgs/development/compilers/clasp/default.nix
blob: 96e0a0f7922271f7761abc8b902f804d2bbca896 (plain)
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
79
80
81
82
83
84
85
86
87
88
{
  lib,
  llvmPackages_18,
  fetchzip,
  sbcl,
  pkg-config,
  fmt_9,
  gmpxx,
  libelf,
  boost,
  libunwind,
  ninja,
}:

let
  inherit (llvmPackages_18) stdenv llvm libclang;
in

stdenv.mkDerivation rec {
  pname = "clasp";
  version = "2.7.0";

  src = fetchzip {
    url = "https://github.com/clasp-developers/clasp/releases/download/${version}/clasp-${version}.tar.gz";
    hash = "sha256-IoEwsMvY/bbb6K6git+7zRGP0DIJDROt69FBQuzApRk=";
  };

  patches = [
    ./remove-unused-command-line-argument.patch
  ];

  # Workaround for https://github.com/clasp-developers/clasp/issues/1590
  postPatch = ''
    echo '(defmethod configure-unit (c (u (eql :git))))' >> src/koga/units.lisp
  '';

  nativeBuildInputs = [
    sbcl
    pkg-config
    fmt_9
    gmpxx
    libelf
    boost
    libunwind
    ninja
    llvm
    libclang
  ];

  ninjaFlags = [
    "-C"
    "build"
  ];

  configurePhase = ''
    export SOURCE_DATE_EPOCH=1
    export ASDF_OUTPUT_TRANSLATIONS=$(pwd):$(pwd)/__fasls
    sbcl --script koga \
      --skip-sync \
      --build-mode=bytecode-faso \
      --cc=$NIX_CC/bin/cc \
      --cxx=$NIX_CC/bin/c++ \
      --reproducible-build \
      --package-path=/ \
      --bin-path=$out/bin \
      --lib-path=$out/lib \
      --dylib-path=$out/lib \
      --share-path=$out/share \
      --pkgconfig-path=$out/lib/pkgconfig
  '';

  postInstall = ''
    # --dylib-path not honored. Fix it in post.
    mv $out/libclasp* $out/lib/
  '';

  meta = {
    description = "Common Lisp implementation based on LLVM with C++ integration";
    license = lib.licenses.lgpl21Plus;
    teams = [ lib.teams.lisp ];
    platforms = [
      "x86_64-linux"
      "x86_64-darwin"
    ];
    homepage = "https://github.com/clasp-developers/clasp";
    mainProgram = "clasp";
  };
}