lol
1{ lib
2, stdenv
3, fetchurl
4, meson
5, ninja
6, pkg-config
7, glib
8, pcre2
9, gtk4
10, pango
11, fribidi
12, vala
13, gi-docgen
14, libxml2
15, perl
16, gettext
17, gnome
18, gobject-introspection
19, dbus
20, xvfb-run
21, shared-mime-info
22, testers
23}:
24
25stdenv.mkDerivation (finalAttrs: {
26 pname = "gtksourceview";
27 version = "5.12.0";
28
29 outputs = [ "out" "dev" "devdoc" ];
30
31 src = let
32 inherit (finalAttrs) pname version;
33 in fetchurl {
34 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
35 hash = "sha256-2vMv9dMVDWOFkX01A6hbngR7oViysDB5MUycAIE/oB8=";
36 };
37
38 patches = [
39 # By default, the library loads syntaxes from XDG_DATA_DIRS and user directory
40 # but not from its own datadr (it assumes it will be in XDG_DATA_DIRS).
41 # Since this is not generally true with Nix, let’s add $out/share unconditionally.
42 ./4.x-nix_share_path.patch
43 ];
44
45 nativeBuildInputs = [
46 meson
47 ninja
48 pkg-config
49 gettext
50 perl
51 gobject-introspection
52 vala
53 gi-docgen
54 gtk4 # for gtk4-update-icon-cache checked during configure
55 ];
56
57 buildInputs = [
58 glib
59 pcre2
60 pango
61 fribidi
62 libxml2
63 ];
64
65 propagatedBuildInputs = [
66 # Required by gtksourceview-5.0.pc
67 gtk4
68 # Used by gtk_source_language_manager_guess_language
69 shared-mime-info
70 ];
71
72 nativeCheckInputs = [
73 xvfb-run
74 dbus
75 ];
76
77 mesonFlags = [
78 "-Ddocumentation=true"
79 ];
80
81 doCheck = stdenv.isLinux;
82
83 checkPhase = ''
84 runHook preCheck
85
86 env \
87 XDG_DATA_DIRS="$XDG_DATA_DIRS:${shared-mime-info}/share" \
88 GTK_A11Y=none \
89 xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
90 --config-file=${dbus}/share/dbus-1/session.conf \
91 meson test --no-rebuild --print-errorlogs
92
93 runHook postCheck
94 '';
95
96 postFixup = ''
97 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
98 moveToOutput "share/doc" "$devdoc"
99 '';
100
101 passthru = {
102 updateScript = gnome.updateScript {
103 packageName = "gtksourceview";
104 attrPath = "gtksourceview5";
105 versionPolicy = "odd-unstable";
106 };
107 };
108
109 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
110
111 meta = with lib; {
112 description = "Source code editing widget for GTK";
113 homepage = "https://gitlab.gnome.org/GNOME/gtksourceview";
114 pkgConfigModules = [ "gtksourceview-5" ];
115 platforms = platforms.unix;
116 license = licenses.lgpl21Plus;
117 maintainers = teams.gnome.members;
118 # https://hydra.nixos.org/build/258191535/nixlog/1
119 broken = stdenv.isDarwin && stdenv.isx86_64;
120 };
121})