@@ -1,7 +1,11 @@
1−{ stdenv, fetchFromGitHub, which, libX11, libXt, fontconfig, freetype
1+{ stdenv, fetchFromGitHub, which
2+, darwin ? null
23, xorgproto ? null
4+, libX11
35, libXext ? null
4−, zlib ? null
6+, libXt ? null
7+, fontconfig ? null
8+, freetype ? null
59, perl ? null # For building web manuals
610}:
711
@@ -16,14 +20,24 @@ stdenv.mkDerivation {
1620 sha256 = "1lp17948q7vpl8rc2bf5a45bc8jqyj0s3zffmks9r25ai42vgb43";
1721 };
1822
23+ patches = [
24+ ./tmpdir.patch
25+ ./darwin-sw_vers.patch
26+ ./darwin-cfframework.patch
27+ ];
28+
1929 postPatch = ''
2030 #hardcoded path
2131 substituteInPlace src/cmd/acme/acme.c \
2232 --replace /lib/font/bit $out/plan9/font
33+
2334 #deprecated flags
2435 find . -type f \
2536 -exec sed -i -e 's/_SVID_SOURCE/_DEFAULT_SOURCE/g' {} \; \
2637 -exec sed -i -e 's/_BSD_SOURCE/_DEFAULT_SOURCE/g' {} \;
38+
39+ substituteInPlace bin/9c \
40+ --replace 'which uniq' '${which}/bin/which uniq'
2741 '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
2842 #add missing ctrl+c\z\x\v keybind for non-Darwin
2943 substituteInPlace src/cmd/acme/text.c \
@@ -34,30 +48,16 @@ stdenv.mkDerivation {
3448 '';
3549
3650 buildInputs = [
37− which perl libX11 fontconfig xorgproto libXt libXext
51+ perl
52+ ] ++ stdenv.lib.optionals (!stdenv.isDarwin) [
53+ xorgproto libX11 libXext libXt fontconfig
3854 freetype # fontsrv wants ft2build.h provides system fonts for acme and sam.
39− ];
55+ ] ++ stdenv.lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
56+ darwin.cf-private Carbon Cocoa IOKit Metal QuartzCore
57+ ]);
4058
4159 builder = ./builder.sh;
42−
43− libX11_dev = libX11.dev;
4460 libXt_dev = libXt.dev;
45− libXext_dev = libXext.dev;
46− fontconfig_dev = fontconfig.dev;
47− freetype_dev = freetype.dev;
48− zlib_dev = zlib.dev;
49−
50− xorgproto_exp = xorgproto;
51− libX11_exp = libX11;
52− libXt_exp = libXt;
53− libXext_exp = libXext;
54− freetype_exp = freetype;
55− zlib_exp = zlib;
56−
57− fontconfig_lib = fontconfig.lib;
58−
59− NIX_LDFLAGS="-lgcc_s";
60− enableParallelBuilding = true;
6161
6262 doInstallCheck = true;
6363 installCheckPhase = ''