1{ stdenv
2, lib
3, fetchurl
4, fetchpatch
5, gettext
6, pkg-config
7, meson
8, ninja
9, gnome
10, glib
11, gtk3
12, gtk4
13, gtkVersion ? "3"
14, gobject-introspection
15, vala
16, python3
17, gi-docgen
18, libxml2
19, gnutls
20, gperf
21, pango
22, pcre2
23, cairo
24, fribidi
25, lz4
26, icu
27, systemd
28, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd
29, nixosTests
30, blackbox-terminal
31}:
32
33stdenv.mkDerivation (finalAttrs: {
34 pname = "vte";
35 version = "0.76.3";
36
37 outputs = [ "out" "dev" ]
38 ++ lib.optional (gtkVersion != null) "devdoc";
39
40 src = fetchurl {
41 url = "mirror://gnome/sources/vte/${lib.versions.majorMinor finalAttrs.version}/vte-${finalAttrs.version}.tar.xz";
42 hash = "sha256-9njpTAVvN3/QAhIUrf9UUMsXLpoIsWCREYHd/3t9XWA=";
43 };
44
45 patches = [
46 # VTE needs a small patch to work with musl:
47 # https://gitlab.gnome.org/GNOME/vte/issues/72
48 # Taken from https://git.alpinelinux.org/aports/tree/community/vte3
49 (fetchpatch {
50 name = "0001-Add-W_EXITCODE-macro-for-non-glibc-systems.patch";
51 url = "https://git.alpinelinux.org/aports/plain/community/vte3/fix-W_EXITCODE.patch?id=4d35c076ce77bfac7655f60c4c3e4c86933ab7dd";
52 hash = "sha256-FkVyhsM0mRUzZmS2Gh172oqwcfXv6PyD6IEgjBhy2uU=";
53 })
54 ];
55
56 nativeBuildInputs = [
57 gettext
58 gobject-introspection
59 gperf
60 libxml2
61 meson
62 ninja
63 pkg-config
64 vala
65 python3
66 gi-docgen
67 ];
68
69 buildInputs = [
70 cairo
71 fribidi
72 gnutls
73 pango # duplicated with propagatedBuildInputs to support gtkVersion == null
74 pcre2
75 lz4
76 icu
77 ] ++ lib.optionals systemdSupport [
78 systemd
79 ];
80
81 # Required by vte-2.91.pc.
82 propagatedBuildInputs = lib.optionals (gtkVersion != null) [
83 (assert (gtkVersion == "3" || gtkVersion == "4");
84 if gtkVersion == "3" then gtk3 else gtk4)
85 glib
86 pango
87 ];
88
89 mesonFlags = [
90 "-Ddocs=true"
91 (lib.mesonBool "gtk3" (gtkVersion == "3"))
92 (lib.mesonBool "gtk4" (gtkVersion == "4"))
93 ] ++ lib.optionals (!systemdSupport) [
94 "-D_systemd=false"
95 ] ++ lib.optionals stdenv.isDarwin [
96 # -Bsymbolic-functions is not supported on darwin
97 "-D_b_symbolic_functions=false"
98 ];
99
100 # error: argument unused during compilation: '-pie' [-Werror,-Wunused-command-line-argument]
101 env.NIX_CFLAGS_COMPILE = toString (lib.optional stdenv.hostPlatform.isMusl "-Wno-unused-command-line-argument"
102 ++ lib.optional stdenv.cc.isClang "-Wno-cast-function-type-strict");
103
104 postPatch = ''
105 patchShebangs perf/*
106 patchShebangs src/parser-seq.py
107 patchShebangs src/modes.py
108 '';
109
110 postFixup = ''
111 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
112 moveToOutput "share/doc" "$devdoc"
113 '';
114
115 passthru = {
116 updateScript = gnome.updateScript {
117 packageName = "vte";
118 versionPolicy = "odd-unstable";
119 };
120 tests = {
121 inherit (nixosTests.terminal-emulators) gnome-terminal lxterminal mlterm roxterm sakura stupidterm terminator termite xfce4-terminal;
122 blackbox-terminal = blackbox-terminal.override { sixelSupport = true; };
123 };
124 };
125
126 meta = with lib; {
127 homepage = "https://www.gnome.org/";
128 description = "Library implementing a terminal emulator widget for GTK";
129 longDescription = ''
130 VTE is a library (libvte) implementing a terminal emulator widget for
131 GTK, and a minimal sample application (vte) using that. Vte is
132 mainly used in gnome-terminal, but can also be used to embed a
133 console/terminal in games, editors, IDEs, etc. VTE supports Unicode and
134 character set conversion, as well as emulating any terminal known to
135 the system's terminfo database.
136 '';
137 license = licenses.lgpl3Plus;
138 maintainers = with maintainers; [ astsmtl antono ] ++ teams.gnome.members;
139 platforms = platforms.unix;
140 };
141})