diff options
Diffstat (limited to 'pkgs/development/libraries/glib/default.nix')
-rw-r--r-- | pkgs/development/libraries/glib/default.nix | 128 |
1 files changed, 83 insertions, 45 deletions
diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix index cd03315c0b3c6..5a7f49ce94ae1 100644 --- a/pkgs/development/libraries/glib/default.nix +++ b/pkgs/development/libraries/glib/default.nix @@ -2,24 +2,27 @@ , lib , stdenv , fetchurl -, fetchpatch , gettext , meson , ninja , pkg-config , perl , python3 -, libiconv, zlib, libffi, pcre2, elfutils, gnome, libselinux, bash, gnum4, gtk-doc, docbook_xsl, docbook_xml_dtd_45, libxslt +, python3Packages +, libiconv, zlib, libffi, pcre2, elfutils, gnome, libselinux, bash, gnum4, libxslt +, docutils, gi-docgen # use util-linuxMinimal to avoid circular dependency (util-linux, systemd, glib) , util-linuxMinimal ? null , buildPackages # this is just for tests (not in the closure of any regular package) -, coreutils, dbus, libxml2, tzdata +, coreutils, dbus, tzdata , desktop-file-utils, shared-mime-info , darwin , makeHardcodeGsettingsPatch , testers +, gobject-introspection +, withIntrospection ? stdenv.buildPlatform.canExecute stdenv.hostPlatform && lib.meta.availableOn stdenv.hostPlatform gobject-introspection }: assert stdenv.isLinux -> util-linuxMinimal != null; @@ -38,16 +41,26 @@ let ln -sr -t "''${!outputInclude}/include/" "''${!outputInclude}"/lib/*/include/* 2>/dev/null || true ''; - buildDocs = stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.hostPlatform.isStatic; + gobject-introspection' = buildPackages.gobject-introspection.override { + propagateFullGlib = false; + # Avoid introducing cairo, which enables gobjectSupport by default. + x11Support = false; + }; + + librarySuffix = if (stdenv.targetPlatform.extensions.library == ".so") then "2.0.so.0" + else if (stdenv.targetPlatform.extensions.library == ".dylib") then "2.0.0.dylib" + else if (stdenv.targetPlatform.extensions.library == ".a") then "2.0.a" + else if (stdenv.targetPlatform.extensions.library == ".dll") then "2.0-0.dll" + else "2.0-0.lib"; in stdenv.mkDerivation (finalAttrs: { pname = "glib"; - version = "2.78.4"; + version = "2.80.0"; src = fetchurl { url = "mirror://gnome/sources/glib/${lib.versions.majorMinor finalAttrs.version}/glib-${finalAttrs.version}.tar.xz"; - sha256 = "sha256-JLjgZy3KEgzDLTlLzLhYROcy4E/nXRi7BXOy28dUj2M="; + hash = "sha256-giipL5KkEhYLE5rmi2NFvSjyRDSnta8VDr4h/1h6Vh0="; }; patches = lib.optionals stdenv.isDarwin [ @@ -56,13 +69,19 @@ stdenv.mkDerivation (finalAttrs: { ./quark_init_on_demand.patch ./gobject_init_on_demand.patch ] ++ [ - (fetchpatch { - name = "GLib-against-PCRE2-10.43.patch"; - url = "https://gitlab.gnome.org/GNOME/glib/-/commit/cce3ae98a2c1966719daabff5a4ec6cf94a846f6.patch"; - hash = "sha256-vgKzb5hQmFQGD8zxRrXnuX9Gpg/TeSrzehlOH2vA1xU="; - }) - + # This patch lets GLib's GDesktopAppInfo API watch and notice changes + # to the Nix user and system profiles. That way, the list of available + # applications shown by the desktop environment is immediately updated + # when the user installs or removes any + # (see <https://issues.guix.gnu.org/35594>). + + # It does so by monitoring /nix/var/nix/profiles (for changes to the system + # profile) and /nix/var/nix/profiles/per-user/USER (for changes to the user + # profile) as well as /etc/profiles/per-user (for chanes to the user + # environment profile) and crawling their share/applications sub-directory when + # changes happen. ./glib-appinfo-watch.patch + ./schema-override-variable.patch # Add support for Pantheon’s terminal emulator. @@ -91,10 +110,6 @@ stdenv.mkDerivation (finalAttrs: { # 3. Tools for desktop environment that cannot go to $bin due to $out depending on them ($out) # * gio-launch-desktop ./split-dev-programs.patch - - # Disable flaky test. - # https://gitlab.gnome.org/GNOME/glib/-/issues/820 - ./skip-timer-test.patch ]; outputs = [ "bin" "out" "dev" "devdoc" ]; @@ -113,48 +128,42 @@ stdenv.mkDerivation (finalAttrs: { util-linuxMinimal # for libmount ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ AppKit Carbon Cocoa CoreFoundation CoreServices Foundation - ]) ++ lib.optionals buildDocs [ - # Note: this needs to be both in buildInputs and nativeBuildInputs. The - # Meson gtkdoc module uses find_program to look it up (-> build dep), but - # glib's own Meson configuration uses the host pkg-config to find its - # version (-> host dep). We could technically go and fix this in glib, add - # pkg-config to depsBuildBuild, but this would be a futile exercise since - # Meson's gtkdoc integration does not support cross compilation[1] anyway - # and this derivation disables the docs build when cross compiling. - # - # [1] https://github.com/mesonbuild/meson/issues/2003 - gtk-doc - ]; + ]); strictDeps = true; + depsBuildBuild = [ + pkg-config # required to find native gi-docgen + ]; + nativeBuildInputs = [ + docutils # for rst2man, rst2html5 meson ninja pkg-config perl python3 + python3Packages.packaging # mostly used to make meson happy + python3Packages.wrapPython # for patchPythonScript gettext libxslt - docbook_xsl - ] ++ lib.optionals buildDocs [ - gtk-doc - docbook_xml_dtd_45 - libxml2 + ] ++ lib.optionals withIntrospection [ + gi-docgen + gobject-introspection' ]; propagatedBuildInputs = [ zlib libffi gettext libiconv ]; mesonFlags = [ - # Avoid the need for gobject introspection binaries in PATH in cross-compiling case. - # Instead we just copy them over from the native output. - "-Dgtk_doc=${lib.boolToString buildDocs}" + "-Ddocumentation=true" # gvariant specification can be built without gi-docgen "-Dnls=enabled" "-Ddevbindir=${placeholder "dev"}/bin" + (lib.mesonEnable "introspection" withIntrospection) + # FIXME: Fails when linking target glib/tests/libconstructor-helper.so + # relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object + "-Dtests=${lib.boolToString (!stdenv.hostPlatform.isStatic)}" ] ++ lib.optionals (!lib.meta.availableOn stdenv.hostPlatform elfutils) [ "-Dlibelf=disabled" - ] ++ lib.optionals (!stdenv.isDarwin) [ - "-Dman=true" # broken on Darwin ] ++ lib.optionals stdenv.isFreeBSD [ "-Db_lundef=false" "-Dxattr=false" @@ -168,14 +177,11 @@ stdenv.mkDerivation (finalAttrs: { ]; postPatch = '' - chmod +x gio/tests/gengiotypefuncs.py - patchShebangs gio/tests/gengiotypefuncs.py - chmod +x docs/reference/gio/concat-files-helper.py - patchShebangs docs/reference/gio/concat-files-helper.py patchShebangs glib/gen-unicode-tables.pl patchShebangs glib/tests/gen-casefold-txt.py patchShebangs glib/tests/gen-casemap-txt.py patchShebangs tools/gen-visibility-macros.py + patchShebangs tests # Needs machine-id, comment the test sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c @@ -211,8 +217,11 @@ stdenv.mkDerivation (finalAttrs: { for i in $dev/bin/*; do moveToOutput "share/bash-completion/completions/''${i##*/}" "$dev" done - '' + lib.optionalString (!buildDocs) '' - cp -r ${buildPackages.glib.devdoc} $devdoc + ''; + + preFixup = lib.optionalString (!stdenv.hostPlatform.isStatic) '' + buildPythonPath ${python3Packages.packaging} + patchPythonScript "$dev/share/glib-2.0/codegen/utils.py" ''; # Move man pages to the same output as their binaries (needs to be @@ -222,6 +231,9 @@ stdenv.mkDerivation (finalAttrs: { for i in $dev/bin/*; do moveToOutput "share/man/man1/''${i##*/}.1.*" "$dev" done + + # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. + moveToOutput "share/doc/glib-2.0" "$devdoc" ''; nativeCheckInputs = [ tzdata desktop-file-utils shared-mime-info ]; @@ -234,8 +246,34 @@ stdenv.mkDerivation (finalAttrs: { export HOME="$TMP" export XDG_DATA_DIRS="${desktop-file-utils}/share:${shared-mime-info}/share" export G_TEST_DBUS_DAEMON="${dbus}/bin/dbus-daemon" - export PATH="$PATH:$(pwd)/gobject" + + # pkg_config_tests expects a PKG_CONFIG_PATH that points to meson-private, wrapped pkg-config + # tries to be clever and picks up the wrong glib at the end. + export PATH="${buildPackages.pkg-config-unwrapped}/bin:$PATH:$(pwd)/gobject" echo "PATH=$PATH" + + # Our gobject-introspection patches make the shared library paths absolute + # in the GIR files. When running tests, the library is not yet installed, + # though, so we need to replace the absolute path with a local one during build. + # We are using a symlink that we will delete before installation. + mkdir -p $out/lib + ln -s $PWD/gobject/libgobject-${librarySuffix} $out/lib/libgobject-${librarySuffix} + ln -s $PWD/gio/libgio-${librarySuffix} $out/lib/libgio-${librarySuffix} + ln -s $PWD/glib/libglib-${librarySuffix} $out/lib/libglib-${librarySuffix} + ''; + + checkPhase = '' + runHook preCheck + + meson test --print-errorlogs + + runHook postCheck + ''; + + postCheck = '' + rm $out/lib/libgobject-${librarySuffix} + rm $out/lib/libgio-${librarySuffix} + rm $out/lib/libglib-${librarySuffix} ''; separateDebugInfo = stdenv.isLinux; |