@@ -1,8 +1,11 @@
1−{ lib
2−, buildPythonPackage, fetchPypi
1+{ lib, stdenv
2+, buildPythonPackage, fetchFromGitHub, fetchpatch
33, pkg-config, cython, docutils
44, kivy-garden
5−, mesa, mtdev, SDL2, SDL2_image, SDL2_ttf, SDL2_mixer, gst_all_1
5+, mesa, mtdev, SDL2, SDL2_image, SDL2_ttf, SDL2_mixer
6+, ApplicationServices, AVFoundation, libcxx
7+, withGstreamer ? true
8+, gst_all_1
69, pillow, requests, pygments
710}:
811
@@ -10,11 +13,21 @@ buildPythonPackage rec {
1013 pname = "Kivy";
1114 version = "2.0.0";
1215
13− src = fetchPypi {
14− inherit pname version;
15− sha256 = "1n0j9046vgjncy50v06r3wcg3q2l37jp8n0cznr64dz48kml8pnj";
16+ # use github since pypi line endings are CRLF and patches do not apply
17+ src = fetchFromGitHub {
18+ owner = "kivy";
19+ repo = "kivy";
20+ rev = version;
21+ sha256 = "sha256-/7GSVQUkYSBEnLVBizMnZAZZxvXVN4r4lskyOgLEcew=";
1622 };
1723
24+ patches = [
25+ (fetchpatch {
26+ url = "https://github.com/kivy/kivy/commit/1c0656c4472817677cf3b08be504de9ca6b1713f.patch";
27+ sha256 = "sha256-phAjMaC3LQuvufwiD0qXzie5B+kezCf8FpKeQMhy/ms=";
28+ })
29+ ];
30+
1831 nativeBuildInputs = [
1932 pkg-config
2033 cython
@@ -22,19 +35,24 @@ buildPythonPackage rec {
2235 ];
2336
2437 buildInputs = [
25− mesa
26− mtdev
2738 SDL2
2839 SDL2_image
2940 SDL2_ttf
3041 SDL2_mixer
31−
42+ ] ++ lib.optionals stdenv.isLinux [
43+ mesa
44+ mtdev
45+ ] ++ lib.optionals stdenv.isDarwin [
46+ ApplicationServices
47+ AVFoundation
48+ libcxx
49+ ] ++ lib.optionals withGstreamer (with gst_all_1; [
3250 # NOTE: The degree to which gstreamer actually works is unclear
33− gst_all_1.gstreamer
34− gst_all_1.gst-plugins-base
35− gst_all_1.gst-plugins-good
36− gst_all_1.gst-plugins-bad
37− ];
51+ gstreamer
52+ gst-plugins-base
53+ gst-plugins-good
54+ gst-plugins-bad
55+ ]);
3856
3957 propagatedBuildInputs = [
4058 kivy-garden
@@ -46,8 +64,12 @@ buildPythonPackage rec {
4664 KIVY_NO_CONFIG = 1;
4765 KIVY_NO_ARGS = 1;
4866 KIVY_NO_FILELOG = 1;
67+ # prefer pkg-config over hardcoded framework paths
68+ USE_OSX_FRAMEWORKS = 0;
69+ # work around python distutils compiling C++ with $CC (see issue #26709)
70+ NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I${lib.getDev libcxx}/include/c++/v1";
4971
50− postPatch = ''
72+ postPatch = lib.optionalString stdenv.isLinux ''
5173 substituteInPlace kivy/lib/mtdev.py \
5274 --replace "LoadLibrary('libmtdev.so.1')" "LoadLibrary('${mtdev}/lib/libmtdev.so.1')"
5375 '';