1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, pkg-config
6, bzip2
7, curl
8, expat
9, fribidi
10, libunibreak
11, sqlite
12, zlib
13, uiTarget ? if !stdenv.isDarwin then "desktop" else "macosx"
14, uiType ? if !stdenv.isDarwin then "qt4" else "cocoa"
15, qt4
16, gtk2
17, AppKit
18, Cocoa
19}:
20
21with lib;
22
23assert elem uiTarget [ "desktop" "macosx" ];
24assert elem uiType [ "qt4" "gtk" "cocoa" ];
25assert uiTarget == "macosx" -> uiType == "cocoa";
26
27# Note: "qt" uiType option mentioned in ${src}/README.build is qt3,
28# which is way to old and no longer in nixpkgs.
29
30stdenv.mkDerivation {
31 pname = "fbreader-${uiType}";
32 version = "0.99.6";
33
34 src = fetchFromGitHub {
35 owner = "geometer";
36 repo = "FBReader";
37 rev = "9e608db14372ae580beae4976eec7241fa069e75";
38 sha256 = "0lzafk02mv0cf2l2a61q5y4743zi913byik4bw1ix0gr1drnsa7y";
39 };
40
41 patches = [
42 ./typecheck.patch
43 (fetchpatch {
44 name = "curl-7_62.diff"; # see https://github.com/geometer/FBReader/pull/311
45 url = "https://github.com/geometer/FBReader/commit/b7c78e965d06f780.diff";
46 sha256 = "1dgnx9wps7hcf8fkidc7037vcf92fr3ccnjx7bgxm9x02j0hngjg";
47 })
48 ];
49
50 postPatch = ''
51 cat << EOF > makefiles/target.mk
52 TARGET_ARCH = ${uiTarget}
53 TARGET_STATUS = release
54 UI_TYPE = ${uiType}
55 EOF
56
57 substituteInPlace makefiles/arch/desktop.mk \
58 --replace ccache "" \
59 --replace moc-qt4 moc
60
61 # libunibreak supersedes liblinebreak
62 substituteInPlace zlibrary/text/Makefile \
63 --replace -llinebreak -lunibreak
64 '';
65
66 nativeBuildInputs = [ pkg-config ];
67
68 buildInputs = [
69 bzip2
70 curl
71 expat
72 fribidi
73 libunibreak
74 sqlite
75 zlib
76 ]
77 ++ optional (uiType == "qt4") qt4
78 ++ optional (uiType == "gtk") gtk2
79 ++ optionals (uiType == "cocoa") [ AppKit Cocoa ];
80
81 makeFlags = [ "INSTALLDIR=$(out)" ];
82
83 NIX_CFLAGS_COMPILE = "-Wno-error=narrowing";
84
85 meta = with lib; {
86 description = "An e-book reader for Linux";
87 homepage = "http://www.fbreader.org/";
88 license = licenses.gpl3;
89 broken = stdenv.isDarwin # untested, might work
90 || uiType == "gtk"; # builds, but the result is unusable, hangs a lot
91 platforms = platforms.unix;
92 maintainers = [ maintainers.coroa ];
93 };
94}