1{
2 lib,
3 stdenv,
4 fetchurl,
5 SDL,
6 check,
7 curl,
8 expat,
9 gperf,
10 gtk2,
11 gtk3,
12 libXcursor,
13 libXrandr,
14 libidn,
15 libjpeg,
16 libjxl,
17 libpng,
18 libwebp,
19 libxml2,
20 makeWrapper,
21 openssl,
22 perlPackages,
23 pkg-config,
24 wrapGAppsHook3,
25 xxd,
26
27 # Netsurf-specific dependencies
28 buildsystem,
29 libcss,
30 libdom,
31 libhubbub,
32 libnsbmp,
33 libnsfb,
34 libnsgif,
35 libnslog,
36 libnspsl,
37 libnsutils,
38 libparserutils,
39 libsvgtiny,
40 libutf8proc,
41 libwapcaplet,
42 nsgenbind,
43
44 # Configuration
45 uilib,
46}:
47
48stdenv.mkDerivation (finalAttrs: {
49 pname = "netsurf";
50 version = "3.11";
51
52 src = fetchurl {
53 url = "http://download.netsurf-browser.org/netsurf/releases/source/netsurf-${finalAttrs.version}-src.tar.gz";
54 hash = "sha256-wopiau/uQo0FOxP4i1xECSIkWXZSLRLq8TfP0y0gHLI=";
55 };
56
57 nativeBuildInputs = [
58 makeWrapper
59 perlPackages.HTMLParser
60 perlPackages.perl
61 pkg-config
62 xxd
63 ]
64 ++ lib.optional (uilib == "gtk2" || uilib == "gtk3") wrapGAppsHook3;
65
66 buildInputs = [
67 check
68 curl
69 gperf
70 libXcursor
71 libXrandr
72 libidn
73 libjpeg
74 libjxl
75 libpng
76 libwebp
77 libxml2
78 openssl
79
80 libcss
81 libdom
82 libhubbub
83 libnsbmp
84 libnsfb
85 libnsgif
86 libnslog
87 libnspsl
88 libnsutils
89 libparserutils
90 libsvgtiny
91 libutf8proc
92 libwapcaplet
93 nsgenbind
94 ]
95 ++ lib.optionals (uilib == "framebuffer") [
96 expat
97 SDL
98 ]
99 ++ lib.optional (uilib == "gtk2") gtk2
100 ++ lib.optional (uilib == "gtk3") gtk3;
101
102 # Since at least 2018 AD, GCC and other compilers run in `-fno-common` mode as
103 # default, in order to comply with C standards and also get rid of some bad
104 # quality code. Because of this, many codebases that weren't updated need to
105 # be patched -- or the `-fcommon` flag should be explicitly passed to the
106 # compiler
107
108 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678
109 # https://github.com/NixOS/nixpkgs/issues/54506
110
111 env.NIX_CFLAGS_COMPILE = "-fcommon";
112
113 env.CFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-D_DARWIN_C_SOURCE";
114
115 env.NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-liconv";
116
117 patchPhase = lib.optionalString stdenv.cc.isClang ''
118 runHook prePatch
119
120 substituteInPlace Makefile \
121 --replace-warn '--trace' '-t' \
122 --replace-warn '-Wimplicit-fallthrough=3' '-Wimplicit-fallthrough'
123
124 runHook postPatch
125 '';
126
127 preConfigure = ''
128 cat <<EOF > Makefile.config
129 override NETSURF_GTK_RES_PATH := $out/share/
130 override NETSURF_USE_GRESOURCE := YES
131 EOF
132 '';
133
134 makeFlags = [
135 "PREFIX=${placeholder "out"}"
136 "TARGET=${uilib}"
137 ];
138
139 meta = {
140 homepage = "https://www.netsurf-browser.org/";
141 description = "Free, open source, small web browser";
142 mainProgram = "netsurf-gtk3";
143 longDescription = ''
144 NetSurf is a free, open source web browser. It is written in C and
145 released under the GNU Public Licence version 2. NetSurf has its own
146 layout and rendering engine entirely written from scratch. It is small and
147 capable of handling many of the web standards in use today.
148 '';
149 license = lib.licenses.gpl2Only;
150 inherit (buildsystem.meta) maintainers platforms;
151 };
152})