about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/networking/browsers/netsurf/browser.nix
blob: 0297301096d63c6168acc28967a8b9145cb2f4de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{ lib
, stdenv
, fetchurl
, SDL
, check
, curl
, expat
, gperf
, gtk2
, gtk3
, libXcursor
, libXrandr
, libidn
, libjpeg
, libjxl
, libpng
, libwebp
, libxml2
, makeWrapper
, openssl
, perlPackages
, pkg-config
, wrapGAppsHook
, xxd

# Netsurf-specific dependencies
, buildsystem
, libcss
, libdom
, libhubbub
, libnsbmp
, libnsfb
, libnsgif
, libnslog
, libnspsl
, libnsutils
, libparserutils
, libsvgtiny
, libutf8proc
, libwapcaplet
, nsgenbind

# Configuration
, uilib
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "netsurf";
  version = "3.11";

  src = fetchurl {
    url = "http://download.netsurf-browser.org/netsurf/releases/source/netsurf-${finalAttrs.version}-src.tar.gz";
    hash = "sha256-wopiau/uQo0FOxP4i1xECSIkWXZSLRLq8TfP0y0gHLI=";
  };

  nativeBuildInputs = [
    makeWrapper
    perlPackages.HTMLParser
    perlPackages.perl
    pkg-config
    xxd
  ]
  ++ lib.optional (uilib == "gtk2" || uilib == "gtk3") wrapGAppsHook;

  buildInputs = [
    check
    curl
    gperf
    libXcursor
    libXrandr
    libidn
    libjpeg
    libjxl
    libpng
    libwebp
    libxml2
    openssl

    libcss
    libdom
    libhubbub
    libnsbmp
    libnsfb
    libnsgif
    libnslog
    libnspsl
    libnsutils
    libparserutils
    libsvgtiny
    libutf8proc
    libwapcaplet
    nsgenbind
  ]
  ++ lib.optionals (uilib == "framebuffer") [ expat SDL ]
  ++ lib.optional (uilib == "gtk2") gtk2
  ++ lib.optional (uilib == "gtk3") gtk3
  ;

  # Since at least 2018 AD, GCC and other compilers run in `-fno-common` mode as
  # default, in order to comply with C standards and also get rid of some bad
  # quality code. Because of this, many codebases that weren't updated need to
  # be patched -- or the `-fcommon` flag should be explicitly passed to the
  # compiler

  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85678
  # https://github.com/NixOS/nixpkgs/issues/54506

  env.NIX_CFLAGS_COMPILE = "-fcommon";

  env.CFLAGS = lib.optionalString stdenv.isDarwin "-D_DARWIN_C_SOURCE";

  patchPhase = lib.optionalString stdenv.cc.isClang ''
    runHook prePatch

    substituteInPlace Makefile \
      --replace-warn '--trace' '-t' \
      --replace-warn '-Wimplicit-fallthrough=3' '-Wimplicit-fallthrough'

    runHook postPatch
  '';

  preConfigure = ''
    cat <<EOF > Makefile.config
    override NETSURF_GTK_RES_PATH  := $out/share/
    override NETSURF_USE_GRESOURCE := YES
    EOF
  '';

  makeFlags = [
    "PREFIX=${placeholder "out"}"
    "TARGET=${uilib}"
  ];

  meta = {
    homepage = "https://www.netsurf-browser.org/";
    description = "A free, open source, small web browser";
    longDescription = ''
      NetSurf is a free, open source web browser. It is written in C and
      released under the GNU Public Licence version 2. NetSurf has its own
      layout and rendering engine entirely written from scratch. It is small and
      capable of handling many of the web standards in use today.
    '';
    license = lib.licenses.gpl2Only;
    inherit (buildsystem.meta) maintainers platforms;
  };
})