-
Notifications
You must be signed in to change notification settings - Fork 13
/
compiler.nix
87 lines (72 loc) · 2.58 KB
/
compiler.nix
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
{ lib
, stdenv
, makeWrapper
, clang
, chez
, racket
, gambit
, nodejs
, idris2-src
, gmp
, zsh
}:
# Uses scheme to bootstrap the build of idris2
let
compiler = lib.makeOverridable stdenv.mkDerivation
rec {
pname = "idris2";
version = "0.5.1";
name = "${pname}-${version}";
executable = "idris2";
src = idris2-src;
strictDeps = true;
nativeBuildInputs = [ makeWrapper clang chez ]
++ lib.optional stdenv.isDarwin [ zsh ];
buildInputs = [ chez gmp ];
prePatch = ''
patchShebangs --build tests
sed 's/''$(GIT_SHA1)/${idris2-src.shortRev or "dirty"}/' -i Makefile
'';
makeFlags = [ "PREFIX=$(out)" ];
# The name of the main executable of pkgs.chez is `scheme`
buildFlags = [ "bootstrap" "SCHEME=scheme" ];
checkInputs = [ gambit nodejs ]; # racket ];
checkFlags = [ "INTERACTIVE=" ];
outputs = [ "out" "support" ];
postInstall = ''
# Remove existing idris2 wrapper that sets incorrect LD_LIBRARY_PATH
rm $out/bin/idris2
# The only thing we need from idris2_app is the actual binary
mv $out/bin/idris2_app/idris2.so $out/bin/idris2
rm $out/bin/idris2_app/*
rmdir $out/bin/idris2_app
mkdir -p $support
mv $out/${name}/ $support/
# idris2 needs to find scheme at runtime to compile
# idris2 installs packages with --install into the path given by
# IDRIS2_PREFIX. We set that to a default of ~/.idris2, to mirror the
# behaviour of the standard Makefile install.
wrapProgram "$out/bin/idris2" \
--set-default CHEZ "${chez}/bin/scheme" \
--run 'export IDRIS2_PREFIX=''${IDRIS2_PREFIX-"$HOME/.idris2"}' \
--suffix IDRIS2_LIBS ':' "$support/${name}/lib" \
--suffix IDRIS2_DATA ':' "$support/${name}/support" \
--suffix IDRIS2_PACKAGE_PATH ':' "$support/${name}" \
--suffix DYLD_LIBRARY_PATH ':' "$support/${name}/lib" \
--suffix LD_LIBRARY_PATH ':' "$support/${name}/lib"
'';
meta = {
description = "A purely functional programming language with first class types";
homepage = "https://github.com/idris-lang/Idris2";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ claymager ];
inherit (chez.meta) platforms;
};
# for compatibility with withLibraries
runtimeLibs = true;
};
in
/* We need one layer of indirection because `useRuntimeLibs` requires our own `.override`,
not the one that comes from callPackage.
*/
{ c = compiler; }