1{
2 lib,
3 stdenv,
4 fetchurl,
5 meson,
6 ninja,
7 pkg-config,
8 gobject-introspection,
9 vala,
10 gi-docgen,
11 glib,
12 gsettings-desktop-schemas,
13 gtk3,
14 enableGlade ? false,
15 glade,
16 xvfb-run,
17 gdk-pixbuf,
18 librsvg,
19 libxml2,
20 hicolor-icon-theme,
21 at-spi2-atk,
22 at-spi2-core,
23 gnome,
24 libhandy,
25 runCommand,
26}:
27
28stdenv.mkDerivation rec {
29 pname = "libhandy";
30 version = "1.8.3";
31
32 outputs =
33 [
34 "out"
35 "dev"
36 "devdoc"
37 ]
38 ++ lib.optionals enableGlade [
39 "glade"
40 ];
41 outputBin = "dev";
42
43 src = fetchurl {
44 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
45 hash = "sha256-BbSXIpBz/1V/ELMm4HTFBm+HQ6MC1IIKuXvLXNLasIc=";
46 };
47
48 depsBuildBuild = [
49 pkg-config
50 ];
51
52 nativeBuildInputs =
53 [
54 gobject-introspection
55 gi-docgen
56 meson
57 ninja
58 pkg-config
59 vala
60 ]
61 ++ lib.optionals enableGlade [
62 libxml2 # for xmllint
63 ];
64
65 buildInputs =
66 [
67 gdk-pixbuf
68 gtk3
69 ]
70 ++ lib.optionals enableGlade [
71 glade
72 ];
73
74 nativeCheckInputs = [
75 xvfb-run
76 at-spi2-atk
77 at-spi2-core
78 librsvg
79 hicolor-icon-theme
80 ];
81
82 mesonFlags = [
83 "-Dgtk_doc=true"
84 "-Dglade_catalog=${if enableGlade then "enabled" else "disabled"}"
85 ];
86
87 # Uses define_variable in pkg-config, but we still need it to use the glade output
88 PKG_CONFIG_GLADEUI_2_0_MODULEDIR = "${placeholder "glade"}/lib/glade/modules";
89 PKG_CONFIG_GLADEUI_2_0_CATALOGDIR = "${placeholder "glade"}/share/glade/catalogs";
90
91 doCheck = !stdenv.hostPlatform.isDarwin;
92
93 checkPhase = ''
94 runHook preCheck
95
96 testEnvironment=(
97 # Disable portal since we cannot run it in tests.
98 HDY_DISABLE_PORTAL=1
99
100 "XDG_DATA_DIRS=${
101 lib.concatStringsSep ":" [
102 # HdySettings needs to be initialized from “org.gnome.desktop.interface” GSettings schema when portal is not used for color scheme.
103 # 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.
104 # See hdy_settings_constructed function in https://gitlab.gnome.org/GNOME/libhandy/-/commit/bb68249b005c445947bfb2bee66c91d0fe9c41a4
105 (glib.getSchemaDataDirPath gsettings-desktop-schemas)
106
107 # Some tests require icons
108 "${hicolor-icon-theme}/share"
109 ]
110 }"
111 )
112 env "''${testEnvironment[@]}" xvfb-run \
113 meson test --print-errorlogs
114
115 runHook postCheck
116 '';
117
118 postFixup = ''
119 # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back.
120 moveToOutput "share/doc" "$devdoc"
121 '';
122
123 passthru =
124 {
125 updateScript = gnome.updateScript {
126 packageName = pname;
127 versionPolicy = "odd-unstable";
128 };
129 }
130 // lib.optionalAttrs (!enableGlade) {
131 glade =
132 let
133 libhandyWithGlade = libhandy.override {
134 enableGlade = true;
135 };
136 in
137 runCommand "${libhandy.name}-glade" { } ''
138 cp -r "${libhandyWithGlade.glade}" "$out"
139 chmod -R +w "$out"
140 sed -e "s#${libhandyWithGlade.out}#${libhandy.out}#g" -e "s#${libhandyWithGlade.glade}#$out#g" -i $(find "$out" -type f)
141 '';
142 };
143
144 meta = with lib; {
145 changelog = "https://gitlab.gnome.org/GNOME/libhandy/-/tags/${version}";
146 description = "Building blocks for modern adaptive GNOME apps";
147 mainProgram = "handy-1-demo";
148 homepage = "https://gitlab.gnome.org/GNOME/libhandy";
149 license = licenses.lgpl21Plus;
150 teams = [ teams.gnome ];
151 platforms = platforms.unix;
152 };
153}