1 { config, lib, stdenv, fetchurl, gettext, meson, ninja, pkg-config, perl, python3
2 , libiconv, zlib, libffi, pcre, libelf, gnome3, libselinux, bash, gnum4, gtk-doc, docbook_xsl, docbook_xml_dtd_45
3 # use util-linuxMinimal to avoid circular dependency (util-linux, systemd, glib)
4 , util-linuxMinimal ? null
7 # this is just for tests (not in the closure of any regular package)
8 , doCheck ? config.doCheckByDefault or false
9 , coreutils, dbus, libxml2, tzdata
10 , desktop-file-utils, shared-mime-info
16 assert stdenv.isLinux -> util-linuxMinimal != null;
19 # * Make it build without python
20 # Problem: an example (test?) program needs it.
21 # Possible solution: disable compilation of this example somehow
22 # Reminder: add 'sed -e 's@python2\.[0-9]@python@' -i
23 # $out/bin/gtester-report' to postInstall if this is solved
25 * Use --enable-installed-tests for GNOME-related packages,
26 and use them as a separately installed tests runned by Hydra
27 (they should test an already installed package)
28 https://wiki.gnome.org/GnomeGoals/InstalledTests
29 * Support org.freedesktop.Application, including D-Bus activation from desktop files
32 # Some packages don't get "Cflags" from pkg-config correctly
33 # and then fail to build when directly including like <glib/...>.
34 # This is intended to be run in postInstall of any package
35 # which has $out/include/ containing just some disjunct directories.
37 for dir in "''${!outputInclude}"/include/*; do
38 cp -r "$dir"/* "''${!outputInclude}/include/"
42 ln -sr -t "''${!outputInclude}/include/" "''${!outputInclude}"/lib/*/include/* 2>/dev/null || true
46 stdenv.mkDerivation rec {
51 url = "mirror://gnome/sources/glib/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
52 sha256 = "sha256-l7yH3ZE2VYmvXLv+oldIM66nobcYQP02Xs0oUsdrnIs=";
55 patches = optionals stdenv.isDarwin [
56 ./darwin-compilation.patch
57 ] ++ optionals stdenv.hostPlatform.isMusl [
58 ./quark_init_on_demand.patch
59 ./gobject_init_on_demand.patch
61 ./schema-override-variable.patch
63 # GLib contains many binaries used for different purposes;
64 # we will install them to different outputs:
65 # 1. Tools for desktop environment ($bin)
66 # * gapplication (non-darwin)
69 # * gio-launch-desktop (symlink to $out)
71 # 2. Development/build tools ($dev)
74 # * glib-compile-resources
75 # * glib-compile-schemas
83 # 3. Tools for desktop environment that cannot go to $bin due to $out depending on them ($out)
84 # * gio-launch-desktop
85 ./split-dev-programs.patch
86 ] ++ optional doCheck ./skip-timer-test.patch;
88 outputs = [ "bin" "out" "dev" "devdoc" ];
90 setupHook = ./setup-hook.sh;
94 bash gnum4 # install glib-gettextize and m4 macros for other apps to use
96 ] ++ optionals stdenv.isLinux [
98 util-linuxMinimal # for libmount
99 ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
100 AppKit Carbon Cocoa CoreFoundation CoreServices Foundation
105 nativeBuildInputs = [
106 meson ninja pkg-config perl python3 gettext gtk-doc docbook_xsl docbook_xml_dtd_45 libxml2
109 propagatedBuildInputs = [ zlib libffi gettext libiconv ];
112 # Avoid the need for gobject introspection binaries in PATH in cross-compiling case.
113 # Instead we just copy them over from the native output.
114 "-Dgtk_doc=${boolToString (stdenv.hostPlatform == stdenv.buildPlatform)}"
116 "-Ddevbindir=${placeholder "dev"}/bin"
119 NIX_CFLAGS_COMPILE = toString [
121 # Default for release buildtype but passed manually because
123 "-DG_DISABLE_CAST_CHECKS"
126 hardeningDisable = [ "pie" ];
129 chmod +x gio/tests/gengiotypefuncs.py
130 patchShebangs gio/tests/gengiotypefuncs.py
131 chmod +x docs/reference/gio/concat-files-helper.py
132 patchShebangs docs/reference/gio/concat-files-helper.py
133 patchShebangs glib/gen-unicode-tables.pl
134 patchShebangs tests/gen-casefold-txt.py
135 patchShebangs tests/gen-casemap-txt.py
138 DETERMINISTIC_BUILD = 1;
141 moveToOutput "share/glib-2.0" "$dev"
142 substituteInPlace "$dev/bin/gdbus-codegen" --replace "$out" "$dev"
143 sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|"
145 # This file is *included* in gtk3 and would introduce runtime reference via __FILE__.
146 sed '1i#line 1 "${pname}-${version}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \
147 -i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c
148 '' + optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
149 cp -r ${buildPackages.glib.devdoc} $devdoc
152 checkInputs = [ tzdata desktop-file-utils shared-mime-info ];
154 preCheck = optionalString doCheck ''
155 export LD_LIBRARY_PATH="$NIX_BUILD_TOP/${pname}-${version}/glib/.libs''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
156 export TZDIR="${tzdata}/share/zoneinfo"
157 export XDG_CACHE_HOME="$TMP"
158 export XDG_RUNTIME_HOME="$TMP"
160 export XDG_DATA_DIRS="${desktop-file-utils}/share:${shared-mime-info}/share"
161 export G_TEST_DBUS_DAEMON="${dbus.daemon}/bin/dbus-daemon"
162 export PATH="$PATH:$(pwd)/gobject"
165 substituteInPlace gio/tests/desktop-files/home/applications/epiphany-weather-for-toronto-island-9c6a4e022b17686306243dada811d550d25eb1fb.desktop \
166 --replace "Exec=/bin/true" "Exec=${coreutils}/bin/true"
167 # Needs machine-id, comment the test
168 sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c
169 sed -e '/g_test_add_func/ s/^\/*/\/\//' -i gio/tests/gdbus-unix-addresses.c
170 # All gschemas fail to pass the test, upstream bug?
171 sed -e '/g_test_add_data_func/ s/^\/*/\/\//' -i gio/tests/gschema-compile.c
172 # Cannot reproduce the failing test_associations on hydra
173 sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c
174 # Needed because of libtool wrappers
175 sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c
180 separateDebugInfo = stdenv.isLinux;
183 gioModuleDir = "lib/gio/modules";
184 makeSchemaPath = dir: name: "${dir}/share/gsettings-schemas/${name}/glib-2.0/schemas";
185 getSchemaPath = pkg: makeSchemaPath pkg pkg.name;
186 inherit flattenInclude;
187 updateScript = gnome3.updateScript { packageName = "glib"; };
191 description = "C library of programming buildings blocks";
192 homepage = "https://www.gtk.org/";
193 license = licenses.lgpl21Plus;
194 maintainers = with maintainers; [ lovek323 raskin worldofpeace ];
195 platforms = platforms.unix;
198 GLib provides the core application building blocks for libraries
199 and applications written in C. It provides the core object
200 system used in GNOME, the main loop implementation, and a large
201 set of utility functions for strings and common data structures.