1{ lib, stdenv, fetchgit, gcc, unstableGitUpdater }:
2
3stdenv.mkDerivation {
4 pname = "cakelisp";
5 # using unstable as it's the only version that builds against gcc-13
6 version = "0.3.0-unstable-2024-04-25";
7
8 src = fetchgit {
9 url = "https://macoy.me/code/macoy/cakelisp";
10 rev = "eb4427f555c3def9d65612672ccfe59e11b14059";
11 hash = "sha256-wFyqAbHrBMFKqMYlBjS6flYHPn3Rxtaiqb1rRmlZrB4=";
12 };
13
14 buildInputs = [ gcc ];
15
16 postPatch = ''
17 substituteInPlace runtime/HotReloading.cake \
18 --replace '"/usr/bin/g++"' '"${gcc}/bin/g++"'
19 substituteInPlace src/ModuleManager.cpp \
20 --replace '"/usr/bin/g++"' '"${gcc}/bin/g++"'
21 '' + lib.optionalString stdenv.isDarwin ''
22 substituteInPlace Build.sh --replace '--export-dynamic' '-export_dynamic'
23 substituteInPlace runtime/HotReloading.cake --replace '--export-dynamic' '-export_dynamic'
24 substituteInPlace Bootstrap.cake --replace '--export-dynamic' '-export_dynamic'
25 '';
26
27 buildPhase = ''
28 runHook preBuild
29 ./Build.sh
30 runHook postBuild
31 '';
32
33 env.NIX_CFLAGS_COMPILE = "-Wno-error=format";
34
35 installPhase = ''
36 runHook preInstall
37 install -Dm755 bin/cakelisp -t $out/bin
38 runHook postInstall
39 '';
40
41 passthru.updateScript = unstableGitUpdater {
42 url = "https://macoy.me/code/macoy/cakelisp";
43 };
44
45 meta = with lib; {
46 description = "Performance-oriented Lisp-like language";
47 mainProgram = "cakelisp";
48 homepage = "https://macoy.me/code/macoy/cakelisp";
49 license = licenses.gpl3Plus;
50 platforms = platforms.darwin ++ platforms.linux;
51 maintainers = [ maintainers.sbond75 ];
52 # never built on aarch64-darwin since first introduction in nixpkgs
53 broken = stdenv.isDarwin && stdenv.isAarch64;
54 };
55}