Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions pkgs/development/libraries/gtk/3.x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
, stdenv
, substituteAll
, fetchurl
, buildPackages
, pkgsBuildBuild
, pkgsBuildTarget
, pkg-config
, gettext
, docbook-xsl-nons
Expand Down Expand Up @@ -39,7 +42,7 @@
, wayland-protocols
, xineramaSupport ? stdenv.isLinux
, cupsSupport ? stdenv.isLinux
, withGtkDoc ? stdenv.isLinux
, withGtkDoc ? stdenv.isLinux && stdenv.buildPlatform == stdenv.hostPlatform
, cups
, AppKit
, Cocoa
Expand Down Expand Up @@ -88,6 +91,8 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [
gettext
gobject-introspection
buildPackages.gdk-pixbuf
buildPackages.glib # for glib-compile-schemas
makeWrapper
meson
ninja
Expand All @@ -100,10 +105,13 @@ stdenv.mkDerivation rec {
gtk-doc
# For xmllint
libxml2
] ++ lib.optionals waylandSupport [
buildPackages.wayland # for wayland-scanner
];

buildInputs = [
libxkbcommon
pkg-config
(libepoxy.override { inherit x11Support; })
isocodes
] ++ lib.optionals stdenv.isDarwin [
Expand Down Expand Up @@ -151,6 +159,8 @@ stdenv.mkDerivation rec {
"-Dbroadway_backend=${lib.boolToString broadwaySupport}"
"-Dx11_backend=${lib.boolToString x11Support}"
"-Dquartz_backend=${lib.boolToString (stdenv.isDarwin && !x11Support)}"
] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-Dintrospection=false"
];

doCheck = false; # needs X11
Expand All @@ -161,7 +171,14 @@ stdenv.mkDerivation rec {
# See: https://developer.gnome.org/gtk3/stable/gtk-building.html#extra-configuration-options
NIX_CFLAGS_COMPILE = "-DG_ENABLE_DEBUG -DG_DISABLE_CAST_CHECKS";

postPatch = ''
postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
substituteInPlace build-aux/meson/post-install.py \
--replace "'pkg-config'" "'${pkgsBuildBuild.pkg-config}/bin/pkg-config'"
substituteInPlace build-aux/meson/post-install.py \
--replace "gtk_bindir = sys.argv[3]" "gtk_bindir = '${buildPackages.gtk3}/bin'"
substituteInPlace build-aux/meson/post-install.py \
--replace "gtk_query_immodules = os.path.join(gtk_bindir" "gtk_query_immodules = os.path.join('${buildPackages.gtk3.dev}/bin'"
'' + ''
# See https://github.com/NixOS/nixpkgs/issues/132259
substituteInPlace meson.build \
--replace "x11_enabled = false" ""
Expand All @@ -181,6 +198,14 @@ stdenv.mkDerivation rec {
patchShebangs ''${files[@]}
'';

# build-aux/meson/post-install.py uses pkg-config to search for
# programs to be run at build-time, so we need to replace
# PKG_CONFIG_PATH (which points to hostPlatform-package .pc's) with
# buildPlatform .pc's
preInstall = if stdenv.hostPlatform == stdenv.buildPlatform then null else ''
export PKG_CONFIG_PATH="${pkgsBuildTarget.glib.dev}/lib/pkgconfig"
'';

postInstall = lib.optionalString (!stdenv.isDarwin) ''
# The updater is needed for nixos env and it's tiny.
moveToOutput bin/gtk-update-icon-cache "$out"
Expand Down