This repository has no description
4.1 kB
173 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 nix-update-script,
49}:
50
51let
52 # libcss with libparserutils/libwapcaplet propagated, so meson's
53 # pkg-config lookup finds them when elinks links against libcss.
54 libcss' = libcss.overrideAttrs (old: {
55 buildInputs = lib.filter (d: d != libparserutils && d != libwapcaplet) (old.buildInputs or [ ]);
56 propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
57 libparserutils
58 libwapcaplet
59 ];
60 });
61
62 # libdom: libhubbub/libwapcaplet propagated, for the same reason.
63 libdom' = libdom.overrideAttrs (old: {
64 buildInputs = lib.filter (d: d != libhubbub && d != libwapcaplet) (old.buildInputs or [ ]);
65 propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
66 libhubbub
67 libwapcaplet
68 ];
69 });
70in
71stdenv.mkDerivation (finalAttrs: {
72 pname = "elinks";
73 version = "0.20.0";
74
75 src = fetchFromGitHub {
76 owner = "rkd77";
77 repo = "elinks";
78 rev = "v${finalAttrs.version}";
79 hash = "sha256-oh9nArQ8dkYL4fLSjnnCHbSnxNxJnQmAWD/6Nu7OiiQ=";
80 };
81
82 outputs = [
83 "out"
84 "man"
85 "doc"
86 ];
87
88 buildInputs = [
89 ncurses
90 bzip2
91 zlib
92 brotli
93 zstd
94 xz
95 openssl
96 libidn2
97 tre
98 expat
99 lua
100 curl
101 libcss'
102 libdom'
103 ]
104 ++ lib.optional stdenv.hostPlatform.isDarwin gettext
105 ++ lib.optional enableGuile guile
106 ++ lib.optional enablePython python
107 ++ lib.optional enablePerl perl;
108
109 nativeBuildInputs = [
110 meson
111 ninja
112 gettext
113 perl
114 python3
115 pkg-config
116 xmlto
117 ];
118
119 env =
120 lib.optionalAttrs stdenv.hostPlatform.isLinux {
121 C_INCLUDE_PATH = "${lib.getInclude gpm}/include";
122 LIBRARY_PATH = "${lib.getLib gpm}/lib";
123 }
124 // lib.optionalAttrs stdenv.hostPlatform.isDarwin {
125 LDFLAGS = "-liconv";
126 };
127
128 strictDeps = true;
129 __structuredAttrs = true;
130
131 mesonFlags =
132 (map (f: lib.mesonBool f true) [
133 "finger"
134 "html-highlight"
135 "gopher"
136 "gemini"
137 "cgi"
138 "nntp"
139 "256-colors"
140 "true-color"
141 "brotli"
142 "lzma"
143 "terminfo"
144 "reproducible"
145 ])
146 ++ [
147 (lib.mesonOption "luapkg" "lua")
148 (lib.mesonBool "gpm" stdenv.hostPlatform.isLinux)
149 (lib.mesonBool "guile" enableGuile)
150 (lib.mesonBool "python" enablePython)
151 (lib.mesonBool "perl" enablePerl)
152 ];
153
154 postPatch = ''
155 patchShebangs doc/tools
156 substituteInPlace doc/tools/asciidoc/docbook.conf \
157 --replace-fail "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" "${docbook_xml_dtd_42}/xml/dtd/docbook/docbookx.dtd"
158 '';
159
160 preConfigure = ''
161 mesonFlags+=("-Dsource-date-epoch=$SOURCE_DATE_EPOCH")
162 '';
163
164 passthru.updateScript = nix-update-script { extraArgs = [ "--flake" ]; };
165
166 meta = {
167 description = "Full-featured text-mode web browser (meson build, PR #515347)";
168 mainProgram = "elinks";
169 homepage = "https://github.com/rkd77/elinks";
170 license = lib.licenses.gpl2Only;
171 platforms = with lib.platforms; linux ++ darwin;
172 };
173})