This repository has no description
4.0 kB
170 lines
1# Replacement for nixpkgs's `elinks`, switched to the meson build from
2# upstream nixpkgs PR #515347 (https://github.com/NixOS/nixpkgs/pull/515347).
3#
4# nixpkgs's autotools build of elinks 0.19.1 is broken against gettext
5# 0.23.1 (autopoint refuses `AM_GNU_GETTEXT` without an `external`
6# argument; further, autoheader then fails on `HAVE_ALLOCA`). The PR
7# sidesteps autotools entirely. We carry it locally until it lands.
8#
9# The PR also moves a few entries from `buildInputs` to
10# `propagatedBuildInputs` on libcss and libdom so they're picked up
11# transitively. Rather than overlaying those packages globally, we
12# tweak them inline here (only this elinks build sees the change).
13{
14 lib,
15 stdenv,
16 fetchFromGitHub,
17 ncurses,
18 bzip2,
19 zlib,
20 brotli,
21 zstd,
22 xz,
23 openssl,
24 meson,
25 ninja,
26 gettext,
27 python3,
28 perl,
29 pkg-config,
30 xmlto,
31 docbook_xml_dtd_42,
32 gpm,
33 libidn2,
34 tre,
35 expat,
36 lua,
37 curl,
38 libcss,
39 libdom,
40 libparserutils,
41 libwapcaplet,
42 libhubbub,
43 enableGuile ? false,
44 guile ? null,
45 enablePython ? false,
46 python ? null,
47 enablePerl ? (!stdenv.hostPlatform.isDarwin) && (stdenv.hostPlatform == stdenv.buildPlatform),
48}:
49
50let
51 # libcss with libparserutils/libwapcaplet propagated, so meson's
52 # pkg-config lookup finds them when elinks links against libcss.
53 libcss' = libcss.overrideAttrs (old: {
54 buildInputs = lib.filter (d: d != libparserutils && d != libwapcaplet) (old.buildInputs or [ ]);
55 propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
56 libparserutils
57 libwapcaplet
58 ];
59 });
60
61 # libdom: libhubbub/libwapcaplet propagated, for the same reason.
62 libdom' = libdom.overrideAttrs (old: {
63 buildInputs = lib.filter (d: d != libhubbub && d != libwapcaplet) (old.buildInputs or [ ]);
64 propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
65 libhubbub
66 libwapcaplet
67 ];
68 });
69in
70stdenv.mkDerivation (finalAttrs: {
71 pname = "elinks";
72 version = "0.19.1";
73
74 src = fetchFromGitHub {
75 owner = "rkd77";
76 repo = "elinks";
77 rev = "v${finalAttrs.version}";
78 hash = "sha256-aQ+q2I6uTVv5kpKBaGJ1xiE/9vv9T7JI05VX/ROkAqA=";
79 };
80
81 outputs = [
82 "out"
83 "man"
84 "doc"
85 ];
86
87 buildInputs = [
88 ncurses
89 bzip2
90 zlib
91 brotli
92 zstd
93 xz
94 openssl
95 libidn2
96 tre
97 expat
98 lua
99 curl
100 libcss'
101 libdom'
102 ]
103 ++ lib.optional stdenv.hostPlatform.isDarwin gettext
104 ++ lib.optional enableGuile guile
105 ++ lib.optional enablePython python
106 ++ lib.optional enablePerl perl;
107
108 nativeBuildInputs = [
109 meson
110 ninja
111 gettext
112 perl
113 python3
114 pkg-config
115 xmlto
116 ];
117
118 env =
119 lib.optionalAttrs stdenv.hostPlatform.isLinux {
120 C_INCLUDE_PATH = "${lib.getInclude gpm}/include";
121 LIBRARY_PATH = "${lib.getLib gpm}/lib";
122 }
123 // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
124 LDFLAGS = "-liconv";
125 };
126
127 strictDeps = true;
128 __structuredAttrs = true;
129
130 mesonFlags =
131 (map (f: lib.mesonBool f true) [
132 "finger"
133 "html-highlight"
134 "gopher"
135 "gemini"
136 "cgi"
137 "nntp"
138 "256-colors"
139 "true-color"
140 "brotli"
141 "lzma"
142 "terminfo"
143 "reproducible"
144 ])
145 ++ [
146 (lib.mesonOption "luapkg" "lua")
147 (lib.mesonBool "gpm" stdenv.hostPlatform.isLinux)
148 (lib.mesonBool "guile" enableGuile)
149 (lib.mesonBool "python" enablePython)
150 (lib.mesonBool "perl" enablePerl)
151 ];
152
153 postPatch = ''
154 patchShebangs doc/tools
155 substituteInPlace doc/tools/asciidoc/docbook.conf \
156 --replace-fail "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" "${docbook_xml_dtd_42}/xml/dtd/docbook/docbookx.dtd"
157 '';
158
159 preConfigure = ''
160 mesonFlags+=("-Dsource-date-epoch=$SOURCE_DATE_EPOCH")
161 '';
162
163 meta = {
164 description = "Full-featured text-mode web browser (meson build, PR #515347)";
165 mainProgram = "elinks";
166 homepage = "https://github.com/rkd77/elinks";
167 license = lib.licenses.gpl2Only;
168 platforms = with lib.platforms; linux ++ darwin;
169 };
170})