git.iko.soy/typeable/nixpkgs
on master help sign in
gtk4: init at 4.0.2

Major API change; adds multimedia and 3D graphics widgets. Changes: - https://gitlab.gnome.org/GNOME/gtk/-/blob/4.0.2/NEWS - https://blog.gtk.org/2020/12/16/gtk-4-0/ Co-authored-by: Jan Tojnar <jtojnar@gmail.com> Co-authored-by: Tad Fisher <tadfisher@gmail.com>

commit44b07653bdae0f008b5f2eb9bdbf4e5096d866f0 authorAndreas Rammhold <andreas@rammhold.de> dateTue 22 Dec 2020, 15:01 (6 years ago) parent44ad80a
3 files changed+248
pkgs/development/libraries/gtk/4.x.nix+232 pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh+11 pkgs/top-level/all-packages.nix+5
pkgs/development/libraries/gtk/4.x.nixnew file+232
@@ -0,0 +1,232 @@
1+{ lib
2+, stdenv
3+, fetchurl
4+, pkg-config
5+, gettext
6+, graphene
7+, docbook-xsl-nons
8+, docbook_xml_dtd_43
9+, gtk-doc
10+, meson
11+, ninja
12+, python3
13+, makeWrapper
14+, shared-mime-info
15+, isocodes
16+, glib
17+, cairo
18+, pango
19+, pandoc
20+, gdk-pixbuf
21+, gobject-introspection
22+, fribidi
23+, xorg
24+, epoxy
25+, json-glib
26+, libxkbcommon
27+, libxml2
28+, librest
29+, libsoup
30+, ffmpeg
31+, gmp
32+, gnome3
33+, gsettings-desktop-schemas
34+, gst_all_1
35+, sassc
36+, trackerSupport ? stdenv.isLinux
37+, tracker
38+, x11Support ? stdenv.isLinux
39+, waylandSupport ? stdenv.isLinux
40+, mesa
41+, vulkan-loader
42+, vulkan-headers
43+, wayland
44+, wayland-protocols
45+, xineramaSupport ? stdenv.isLinux
46+, cupsSupport ? stdenv.isLinux
47+, withGtkDoc ? stdenv.isLinux
48+, cups ? null
49+, AppKit
50+, Cocoa
51+, broadwaySupport ? true
52+}:
53+
54+assert cupsSupport -> cups != null;
55+
56+stdenv.mkDerivation rec {
57+ pname = "gtk4";
58+ version = "4.0.2";
59+
60+ outputs = [ "out" "dev" ] ++ lib.optional withGtkDoc "devdoc";
61+ outputBin = "dev";
62+
63+ setupHooks = [
64+ ./hooks/gtk4-clean-immodules-cache.sh
65+ ./hooks/drop-icon-theme-cache.sh
66+ ];
67+
68+ src = fetchurl {
69+ url = "mirror://gnome/sources/gtk/${lib.versions.majorMinor version}/gtk-${version}.tar.xz";
70+ sha256 = "115w3mzwm1xsi1q85qvwfm2yxpsjs2rcajgddzbnwhjicyn0frv2";
71+ };
72+
73+ nativeBuildInputs = [
74+ gettext
75+ gobject-introspection
76+ makeWrapper
77+ meson
78+ ninja
79+ pkg-config
80+ python3
81+ sassc
82+ ] ++ setupHooks ++ lib.optionals withGtkDoc [
83+ pandoc
84+ docbook_xml_dtd_43
85+ docbook-xsl-nons
86+ gtk-doc
87+ # For xmllint
88+ libxml2
89+ ];
90+
91+ buildInputs = [
92+ libxkbcommon
93+ epoxy
94+ json-glib
95+ isocodes
96+ vulkan-headers
97+ librest
98+ libsoup
99+ ffmpeg
100+ gst_all_1.gst-plugins-base
101+ gst_all_1.gst-plugins-bad
102+ fribidi
103+ ] ++ (with xorg; [
104+ libICE
105+ libSM
106+ libXcomposite
107+ libXcursor
108+ libXi
109+ libXrandr
110+ libXrender
111+ ]) ++ lib.optionals stdenv.isDarwin [
112+ AppKit
113+ ] ++ lib.optionals trackerSupport [
114+ tracker
115+ ] ++ lib.optionals waylandSupport [
116+ mesa
117+ wayland
118+ wayland-protocols
119+ ] ++ lib.optionals xineramaSupport [
120+ xorg.libXinerama
121+ ] ++ lib.optionals cupsSupport [
122+ cups
123+ ] ++ lib.optionals stdenv.isDarwin [
124+ Cocoa
125+ ];
126+ #TODO: colord?
127+
128+ propagatedBuildInputs = [
129+ # Required by pkg-config files.
130+ cairo
131+ gdk-pixbuf
132+ glib
133+ graphene
134+ pango
135+ vulkan-loader # TODO: Possibly not used on Darwin
136+
137+ # Required for GSettings schemas at runtime.
138+ # Will be picked up by wrapGAppsHook.
139+ gsettings-desktop-schemas
140+ ];
141+
142+ mesonFlags = [
143+ "-Dgtk_doc=${lib.boolToString withGtkDoc}"
144+ "-Dtests=false"
145+ "-Dtracker3=${lib.boolToString trackerSupport}"
146+ "-Dbroadway_backend=${lib.boolToString broadwaySupport}"
147+ ];
148+
149+ doCheck = false; # needs X11
150+
151+ separateDebugInfo = stdenv.isLinux;
152+
153+ # These are the defines that'd you'd get with --enable-debug=minimum (default).
154+ # See: https://developer.gnome.org/gtk3/stable/gtk-building.html#extra-configuration-options
155+ NIX_CFLAGS_COMPILE = "-DG_ENABLE_DEBUG -DG_DISABLE_CAST_CHECKS";
156+
157+ postPatch = ''
158+ files=(
159+ build-aux/meson/post-install.py
160+ demos/gtk-demo/geninclude.py
161+ gdk/broadway/gen-c-array.py
162+ gdk/gen-gdk-gresources-xml.py
163+ gtk/gen-gtk-gresources-xml.py
164+ gtk/gentypefuncs.py
165+ docs/reference/gtk/gtk-markdown-to-docbook
166+ )
167+
168+ chmod +x ''${files[@]}
169+ patchShebangs ''${files[@]}
170+ '';
171+
172+ postBuild = lib.optionalString withGtkDoc ''
173+ # Meson not building `custom_target`s passed to `custom_files` argument of `gnome.gtkdoc` function
174+ # as part of the `install` target. We have to build the docs manually first.
175+ # https://github.com/mesonbuild/meson/issues/2831
176+ ninja g{t,d,s}k4-doc
177+ '';
178+
179+ preInstall = ''
180+ OLD_PATH="$PATH"
181+ PATH="$PATH:$dev/bin" # so the install script finds gtk4-update-icon-cache
182+ '';
183+
184+ postInstall = ''
185+ PATH="$OLD_PATH"
186+ '' + lib.optionalString (!stdenv.isDarwin) ''
187+ # The updater is needed for nixos env and it's tiny.
188+ moveToOutput bin/gtk4-update-icon-cache "$out"
189+ # Launcher
190+ moveToOutput bin/gtk-launch "$out"
191+
192+ # TODO: patch glib directly
193+ for f in $dev/bin/gtk4-encode-symbolic-svg; do
194+ wrapProgram $f --prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
195+ done
196+ '';
197+
198+ # Wrap demos
199+ postFixup = lib.optionalString (!stdenv.isDarwin) ''
200+ demos=(gtk4-demo gtk4-demo-application gtk4-icon-browser gtk4-widget-factory)
201+
202+ for program in ''${demos[@]}; do
203+ wrapProgram $dev/bin/$program \
204+ --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH:$out/share/gsettings-schemas/${pname}-${version}"
205+ done
206+ '';
207+
208+ passthru = {
209+ updateScript = gnome3.updateScript {
210+ packageName = "gtk";
211+ attrPath = "gtk4";
212+ };
213+ };
214+
215+ meta = with lib; {
216+ description = "A multi-platform toolkit for creating graphical user interfaces";
217+ longDescription = ''
218+ GTK is a highly usable, feature rich toolkit for creating
219+ graphical user interfaces which boasts cross platform
220+ compatibility and an easy to use API. GTK it is written in C,
221+ but has bindings to many other popular programming languages
222+ such as C++, Python and C# among others. GTK is licensed
223+ under the GNU LGPL 2.1 allowing development of both free and
224+ proprietary software with GTK without any license fees or
225+ royalties.
226+ '';
227+ homepage = "https://www.gtk.org/";
228+ license = licenses.lgpl2Plus;
229+ maintainers = with maintainers; [ raskin vcunat lethalman worldofpeace ];
230+ platforms = platforms.all;
231+ };
232+}
pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.shnew file+11
@@ -0,0 +1,11 @@
1+# shellcheck shell=bash
2+
3+fixupOutputHooks+=(_gtk4CleanComments)
4+
5+# Clean comments that link to generator of the file
6+_gtk4CleanComments() {
7+ local f="${prefix:?}/lib/gtk-4.0/4.0.0/immodules.cache"
8+ if [ -f "$f" ]; then
9+ sed 's|Created by .*bin/gtk-query-|Created by bin/gtk-query-|' -i "$f"
10+ fi
11+}
pkgs/top-level/all-packages.nix+5
@@ -14026,6 +14026,11 @@ in
1402614026 inherit (darwin.apple_sdk.frameworks) AppKit Cocoa;
1402714027 };
1402814028
14029+ gtk4 = callPackage ../development/libraries/gtk/4.x.nix {
14030+ inherit (darwin.apple_sdk.frameworks) AppKit Cocoa;
14031+ };
14032+
14033+
1402914034 # On darwin gtk uses cocoa by default instead of x11.
1403014035 gtk3-x11 = gtk3.override {
1403114036 cairo = cairo.override { x11Support = true; };