summaryrefslogtreecommitdiffstats
path: root/pkgs/development/compilers/clasp/default.nix
blob: e3a955f8a2d1d2c3f3b167ef0879985d8e0bc995 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
{
  lib,
  llvmPackages_22,
  fetchzip,
  ninja,
  sbcl,
  pkg-config,
  writableTmpDirAsHomeHook,
  boost,
  fmt,
  gmpxx,
  libelf,
}:

let
  inherit (llvmPackages_22)
    stdenv
    llvm
    libclang
    libunwind
    ;
in

stdenv.mkDerivation (finalAttrs: {
  pname = "clasp";
  version = "3.0.1";

  src = fetchzip {
    url = "https://github.com/clasp-developers/clasp/releases/download/${finalAttrs.version}/clasp-${finalAttrs.version}.tar.gz";
    hash = "sha256-C6FwbLz/kjBcuI3225TczWaInkbQ3chtDhWCYh+a/2E=";
  };

  __structuredAttrs = true;
  strictDeps = true;

  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 = [
    llvm.dev
    ninja
    pkg-config
    sbcl
    writableTmpDirAsHomeHook
  ];

  buildInputs = [
    boost
    fmt
    gmpxx
    libclang
    libelf
    libunwind
    llvm
  ];

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

  configurePhase = ''
    runHook preConfigure
    export SOURCE_DATE_EPOCH=1
    sbcl --script koga \
      --skip-sync \
      --cc=$NIX_CC/bin/cc \
      --cxx=$NIX_CC/bin/c++ \
      --jobs=$NIX_BUILD_CORES \
      --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
    runHook postConfigure
  '';

  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"
    ];
    homepage = "https://github.com/clasp-developers/clasp";
    mainProgram = "clasp";
  };
})