1{ lib
2, stdenv
3, fetchFromGitLab
4, gi-docgen
5, meson
6, ninja
7, pkg-config
8, sassc
9, vala
10, gobject-introspection
11, fribidi
12, glib
13, gtk4
14, gnome
15, gsettings-desktop-schemas
16, xvfb-run
17, AppKit
18, Foundation
19}:
20
21stdenv.mkDerivation rec {
22 pname = "libadwaita";
23 version = "1.3.5";
24
25 outputs = [ "out" "dev" "devdoc" ];
26 outputBin = "devdoc"; # demo app
27
28 src = fetchFromGitLab {
29 domain = "gitlab.gnome.org";
30 owner = "GNOME";
31 repo = "libadwaita";
32 rev = version;
33 hash = "sha256-lxNIysW2uth4Hp6NHjo0vWHupITb9qWkkdG8YEDLrUE=";
34 };
35
36 depsBuildBuild = [
37 pkg-config
38 ];
39
40 nativeBuildInputs = [
41 gi-docgen
42 meson
43 ninja
44 pkg-config
45 sassc
46 vala
47 gobject-introspection
48 ];
49
50 mesonFlags = [
51 "-Dgtk_doc=true"
52 ] ++ lib.optionals (!doCheck) [
53 "-Dtests=false"
54 ];
55
56 buildInputs = [
57 fribidi
58 ] ++ lib.optionals stdenv.isDarwin [
59 AppKit
60 Foundation
61 ];
62
63 propagatedBuildInputs = [
64 gtk4
65 ];
66
67 nativeCheckInputs = [
68 gnome.adwaita-icon-theme
69 ] ++ lib.optionals (!stdenv.isDarwin) [
70 xvfb-run
71 ];
72
73 # Tests had to be disabled on Darwin because test-button-content fails
74 #
75 # not ok /Adwaita/ButtonContent/style_class_button - Gdk-FATAL-CRITICAL:
76 # gdk_macos_monitor_get_workarea: assertion 'GDK_IS_MACOS_MONITOR (self)' failed
77 doCheck = !stdenv.isDarwin;
78
79 checkPhase = ''
80 runHook preCheck
81
82 testEnvironment=(
83 # Disable portal since we cannot run it in tests.
84 ADW_DISABLE_PORTAL=1
85
86 # AdwSettings needs to be initialized from “org.gnome.desktop.interface” GSettings schema when portal is not used for color scheme.
87 # It will not actually be used since the “color-scheme” key will only have been introduced in GNOME 42, falling back to detecting theme name.
88 # See adw_settings_constructed function in https://gitlab.gnome.org/GNOME/libadwaita/commit/60ec69f0a5d49cad8a6d79e4ecefd06dc6e3db12
89 "XDG_DATA_DIRS=${glib.getSchemaDataDirPath gsettings-desktop-schemas}"
90
91 # Tests need a cache directory
92 "HOME=$TMPDIR"
93 )
94 env "''${testEnvironment[@]}" ${lib.optionalString (!stdenv.isDarwin) "xvfb-run"} \
95 meson test --print-errorlogs
96
97 runHook postCheck
98 '';
99
100 postFixup = ''
101 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
102 moveToOutput "share/doc" "$devdoc"
103 '';
104
105 passthru = {
106 updateScript = gnome.updateScript {
107 packageName = pname;
108 };
109 };
110
111 meta = with lib; {
112 changelog = "https://gitlab.gnome.org/GNOME/libadwaita/-/blob/${src.rev}/NEWS";
113 description = "Library to help with developing UI for mobile devices using GTK/GNOME";
114 homepage = "https://gitlab.gnome.org/GNOME/libadwaita";
115 license = licenses.lgpl21Plus;
116 maintainers = teams.gnome.members ++ (with maintainers; [ dotlambda ]);
117 platforms = platforms.unix;
118 };
119}