1{ stdenv, buildPackages, callPackage }:
2
3let
4 chezArch =
5 /**/ if stdenv.hostPlatform.isAarch then "arm${toString stdenv.hostPlatform.parsed.cpu.bits}"
6 else if stdenv.hostPlatform.isx86_32 then "i3"
7 else if stdenv.hostPlatform.isx86_64 then "a6"
8 else if stdenv.hostPlatform.isPower then "ppc${toString stdenv.hostPlatform.parsed.cpu.bits}"
9 else throw "Add ${stdenv.hostPlatform.parsed.cpu.arch} to chezArch to enable building chez-racket";
10
11 chezOs =
12 /**/ if stdenv.hostPlatform.isDarwin then "osx"
13 else if stdenv.hostPlatform.isFreeBSD then "fb"
14 else if stdenv.hostPlatform.isLinux then "le"
15 else if stdenv.hostPlatform.isNetBSD then "nb"
16 else if stdenv.hostPlatform.isOpenBSD then "ob"
17 else throw "Add ${stdenv.hostPlatform.uname.system} to chezOs to enable building chez-racket";
18
19 inherit (stdenv.hostPlatform) system;
20 chezSystem = "t${chezArch}${chezOs}";
21 # Chez Scheme uses an ad-hoc `configure`, hence we don't use the usual
22 # stdenv abstractions.
23 forBoot = {
24 pname = "chez-scheme-racket-boot";
25 configurePhase = ''
26 runHook preConfigure
27 ./configure --pb ZLIB=$ZLIB LZ4=$LZ4
28 runHook postConfigure
29 '';
30 makeFlags = [ "${chezSystem}.bootquick" ];
31 installPhase = ''
32 runHook preInstall
33 mkdir -p $out
34 pushd boot
35 mv $(ls -1 | grep -v "^pb$") -t $out
36 popd
37 runHook postInstall
38 '';
39 };
40 boot = buildPackages.callPackage (import ./shared.nix forBoot) {};
41 forFinal = {
42 pname = "chez-scheme-racket";
43 configurePhase = ''
44 runHook preConfigure
45 cp -r ${boot}/* -t ./boot
46 ./configure -m=${chezSystem} --installprefix=$out --installman=$out/share/man ZLIB=$ZLIB LZ4=$LZ4
47 runHook postConfigure
48 '';
49 preBuild = ''
50 pushd ${chezSystem}/c
51 '';
52 postBuild = ''
53 popd
54 '';
55 setupHook = ./setup-hook.sh;
56 };
57 final = callPackage (import ./shared.nix forFinal) {};
58in
59final