1{ lib, fetchFromGitHub, fetchpatch, makeWrapper, clang, haskellPackages }:
2
3haskellPackages.mkDerivation rec {
4 pname = "carp";
5 version = "0.5.5";
6
7 src = fetchFromGitHub {
8 owner = "carp-lang";
9 repo = "Carp";
10 rev = "v${version}";
11 sha256 = "sha256-B7SBzjegFzL2gGivIJE6BZcLD3f0Bsh8yndjScG2TZI=";
12 };
13
14 patches = [
15 # Compat with GHC 9.2 / Stackage LTS 20, can be dropped at the next release
16 # https://github.com/carp-lang/Carp/pull/1449
17 (fetchpatch {
18 name = "carp-lts-20.patch";
19 url = "https://github.com/carp-lang/Carp/commit/25f50c92a57cc91b6cb4ec48df658439f936b641.patch";
20 sha256 = "14yjv0hcvw1qyjmrhksrj6chac3n14d1f1gcaxldfa05llrbfqk0";
21 })
22 ];
23
24 # -Werror breaks build with GHC >= 9.0
25 # https://github.com/carp-lang/Carp/issues/1386
26 postPatch = ''
27 substituteInPlace CarpHask.cabal --replace "-Werror" ""
28 '';
29
30 buildTools = [ makeWrapper ];
31
32 executableHaskellDepends = with haskellPackages; [
33 HUnit blaze-markup blaze-html split ansi-terminal cmark
34 edit-distance hashable open-browser optparse-applicative
35 ];
36
37 isExecutable = true;
38
39 # The carp executable must know where to find its core libraries and other
40 # files. Set the environment variable CARP_DIR so that it points to the root
41 # of the Carp repo. See:
42 # https://github.com/carp-lang/Carp/blob/master/docs/Install.md#setting-the-carp_dir
43 #
44 # Also, clang must be available run-time because carp is compiled to C which
45 # is then compiled with clang.
46 postInstall = ''
47 wrapProgram $out/bin/carp \
48 --set CARP_DIR $src \
49 --prefix PATH : ${clang}/bin
50 wrapProgram $out/bin/carp-header-parse \
51 --set CARP_DIR $src \
52 --prefix PATH : ${clang}/bin
53 '';
54
55 description = "A statically typed lisp, without a GC, for real-time applications";
56 homepage = "https://github.com/carp-lang/Carp";
57 license = lib.licenses.asl20;
58 maintainers = with lib.maintainers; [ jluttine ];
59
60 # Windows not (yet) supported.
61 platforms = with lib.platforms; unix ++ darwin;
62}