@@ -1,4 +1,4 @@
1−{ stdenv, fetchurl, makeWrapper, bootstrap-chicken ? null }:
1+{ stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
22
33let
44 version = "4.13.0";
@@ -21,31 +21,39 @@ stdenv.mkDerivation {
2121 sha256 = "0hvckhi5gfny3mlva6d7y9pmx7cbwvq0r7mk11k3sdiik9hlkmdd";
2222 };
2323
24− setupHook = lib.ifEnable (bootstrap-chicken != null) ./setup-hook.sh;
24+ setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
2525
26− buildFlags = [ "PLATFORM=${platform}" "PREFIX=$(out)" "VARDIR=$(out)/var/lib" ];
27− installFlags = [ "PLATFORM=${platform}" "PREFIX=$(out)" "VARDIR=$(out)/var/lib" ];
26+ # -fno-strict-overflow is not a supported argument in clang on darwin
27+ hardeningDisable = lib.optionals stdenv.isDarwin ["strictoverflow"];
28+
29+ makeFlags = [
30+ "PLATFORM=${platform}" "PREFIX=$(out)"
31+ "VARDIR=$(out)/var/lib"
32+ ] ++ (lib.optionals stdenv.isDarwin [
33+ "XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
34+ "C_COMPILER=$(CC)"
35+ ]);
2836
2937 # We need a bootstrap-chicken to regenerate the c-files after
3038 # applying a patch to add support for CHICKEN_REPOSITORY_EXTRA
31− patches = lib.ifEnable (bootstrap-chicken != null) [
39+ patches = lib.optionals (bootstrap-chicken != null) [
3240 ./0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch
3341 ];
3442
3543 buildInputs = [
3644 makeWrapper
37− ] ++ (lib.ifEnable (bootstrap-chicken != null) [
45+ ] ++ (lib.optionals (bootstrap-chicken != null) [
3846 bootstrap-chicken
3947 ]);
4048
41− preBuild = lib.ifEnable (bootstrap-chicken != null) ''
49+ preBuild = lib.optionalString (bootstrap-chicken != null) ''
4250 # Backup the build* files - those are generated from hostname,
4351 # git-tag, etc. and we don't need/want that
4452 mkdir -p build-backup
4553 mv buildid buildbranch buildtag.h build-backup
4654
4755 # Regenerate eval.c after the patch
48− make spotless $buildFlags
56+ make spotless $makeFlags
4957
5058 mv build-backup/* .
5159 '';
@@ -64,7 +72,7 @@ stdenv.mkDerivation {
6472 homepage = "http://www.call-cc.org/";
6573 license = stdenv.lib.licenses.bsd3;
6674 maintainers = with stdenv.lib.maintainers; [ corngood ];
67− platforms = stdenv.lib.platforms.linux; # Maybe other non-darwin Unix
75+ platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin; # Maybe other Unix
6876 description = "A portable compiler for the Scheme programming language";
6977 longDescription = ''
7078 CHICKEN is a compiler for the Scheme programming language.