@@ -1,38 +1,68 @@
1−{ stdenv, fetchurl, pkgconfig, bzip2, curl, expat, fribidi
2−, libunibreak, qt4, sqlite, zlib }:
1+{ stdenv, fetchFromGitHub, pkgconfig
2+, bzip2, curl, expat, fribidi, libunibreak, sqlite, zlib
3+, uiTarget ? if !stdenv.isDarwin then "desktop" else "macosx"
4+, uiType ? if !stdenv.isDarwin then "qt4" else "cocoa"
5+, qt4, gtk2
6+, AppKit, Cocoa
7+}:
8+
9+with stdenv.lib;
10+
11+assert elem uiTarget [ "desktop" "macosx" ];
12+assert elem uiType [ "qt4" "gtk" "cocoa" ];
13+assert uiTarget == "macosx" -> uiType == "cocoa";
14+
15+# Note: "qt" uiType option mentioned in ${src}/README.build is qt3,
16+# which is way to old and no longer in nixpkgs.
317
418stdenv.mkDerivation {
5− name = "fbreader-0.99.4";
19+ name = "fbreader-${uiType}-0.99.6";
620
7− src = fetchurl {
8− url = https://fbreader.org/files/desktop/fbreader-sources-0.99.4.tgz;
9− sha256 = "1sdq3vvwkq4bkyrvh0p884d66gaddz8hlab3m798ji9ixbak2z1x";
21+ src = fetchFromGitHub {
22+ owner = "geometer";
23+ repo = "FBReader";
24+ rev = "9e608db14372ae580beae4976eec7241fa069e75";
25+ sha256 = "0lzafk02mv0cf2l2a61q5y4743zi913byik4bw1ix0gr1drnsa7y";
1026 };
1127
28+ patches = [ ./typecheck.patch ];
29+
30+ postPatch = ''
31+ cat << EOF > makefiles/target.mk
32+ TARGET_ARCH = ${uiTarget}
33+ TARGET_STATUS = release
34+ UI_TYPE = ${uiType}
35+ EOF
36+
37+ substituteInPlace makefiles/arch/desktop.mk \
38+ --replace ccache "" \
39+ --replace moc-qt4 moc
40+
41+ # libunibreak supersedes liblinebreak
42+ substituteInPlace zlibrary/text/Makefile \
43+ --replace -llinebreak -lunibreak
44+ '';
45+
1246 nativeBuildInputs = [ pkgconfig ];
47+
1348 buildInputs = [
14− bzip2 curl expat fribidi libunibreak
15− qt4 sqlite zlib
16− ];
49+ bzip2 curl expat fribidi libunibreak sqlite zlib
50+ ]
51+ ++ optional (uiType == "qt4") qt4
52+ ++ optional (uiType == "gtk") gtk2
53+ ++ optionals (uiType == "cocoa") [ AppKit Cocoa ];
1754
1855 makeFlags = "INSTALLDIR=$(out)";
1956
2057 NIX_CFLAGS_COMPILE = [ "-Wno-error=narrowing" ]; # since gcc-6
2158
22− patchPhase = ''
23− # don't try to use ccache
24− substituteInPlace makefiles/arch/desktop.mk \
25− --replace "CCACHE = " "# CCACHE = "
26−
27− substituteInPlace fbreader/desktop/Makefile \
28− --replace "/usr/share" "$out/share"
29− '';
30−
3159 meta = with stdenv.lib; {
3260 description = "An e-book reader for Linux";
3361 homepage = http://www.fbreader.org/;
3462 license = licenses.gpl3;
35− platforms = platforms.linux; # possibly also on unix general
63+ broken = stdenv.isDarwin # untested, might work
64+ || uiType == "gtk"; # builds, but the result is unusable, hangs a lot
65+ platforms = platforms.unix;
3666 maintainers = [ maintainers.coroa ];
37− };
67+ };
3868}