diff --git a/pkgs/development/libraries/glib/default.nix b/pkgs/development/libraries/glib/default.nix index 37275489cc3d..024ccf2a4537 100644 --- a/pkgs/development/libraries/glib/default.nix +++ b/pkgs/development/libraries/glib/default.nix @@ -8,6 +8,7 @@ , doCheck ? stdenv.config.doCheckByDefault or false , coreutils, dbus, libxml2, tzdata , desktop-file-utils, shared-mime-info +, darwin }: with stdenv.lib; @@ -44,6 +45,7 @@ let ln -sr -t "''${!outputInclude}/include/" "''${!outputInclude}"/lib/*/include/* 2>/dev/null || true ''; + binPrograms = optional (!stdenv.isDarwin) "gapplication" ++ [ "gdbus" "gio" "gsettings" ]; version = "2.58.2"; in @@ -83,7 +85,12 @@ stdenv.mkDerivation rec { ] ++ optionals stdenv.isLinux [ libselinux utillinuxMinimal # for libmount - ]; + ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ + AppKit Carbon Cocoa CoreFoundation CoreServices Foundation + # Needed for CFURLCreateFromFSRef, etc. which have deen deprecated + # since 10.9 and are not part of swift-corelibs CoreFoundation. + darwin.cf-private + ]); nativeBuildInputs = [ meson ninja pkgconfig perl python3 gettext gtk-doc docbook_xsl docbook_xml_dtd_45 glibcLocales @@ -121,15 +128,17 @@ stdenv.mkDerivation rec { postInstall = '' mkdir -p $bin/bin - for app in gapplication gdbus gio gsettings; do + for app in ${concatStringsSep " " binPrograms}; do mv "$dev/bin/$app" "$bin/bin" done + '' + optionalString (!stdenv.isDarwin) '' # Add gio-launch-desktop to $out so we can refer to it from $dev mkdir $out/bin mv "$dev/bin/gio-launch-desktop" "$out/bin/" ln -s "$out/bin/gio-launch-desktop" "$bin/bin/" + '' + '' moveToOutput "share/glib-2.0" "$dev" substituteInPlace "$dev/bin/gdbus-codegen" --replace "$out" "$dev" sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|" diff --git a/pkgs/development/tools/build-managers/meson/default.nix b/pkgs/development/tools/build-managers/meson/default.nix index 17938ab47b37..96e044073259 100644 --- a/pkgs/development/tools/build-managers/meson/default.nix +++ b/pkgs/development/tools/build-managers/meson/default.nix @@ -44,6 +44,13 @@ python3Packages.buildPythonApplication rec { src = ./fix-rpath.patch; inherit (builtins) storeDir; }) + ] ++ lib.optionals stdenv.isDarwin [ + # We use custom Clang, which makes Meson think *not Apple*, while still + # relying on system linker. When it detects standard Clang, Meson will + # pass it `-Wl,-O1` flag but optimizations are not recognized by + # Mac linker. + # https://github.com/mesonbuild/meson/issues/4784 + ./fix-objc-linking.patch ]; setupHook = ./setup-hook.sh; diff --git a/pkgs/development/tools/build-managers/meson/fix-objc-linking.patch b/pkgs/development/tools/build-managers/meson/fix-objc-linking.patch new file mode 100644 index 000000000000..60a205828f5d --- /dev/null +++ b/pkgs/development/tools/build-managers/meson/fix-objc-linking.patch @@ -0,0 +1,20 @@ +--- a/mesonbuild/environment.py ++++ b/mesonbuild/environment.py +@@ -795,7 +795,7 @@ + compiler_type = self.get_gnu_compiler_type(defines) + version = self.get_gnu_version_from_defines(defines) + return GnuObjCCompiler(ccache + compiler, version, compiler_type, is_cross, exe_wrap, defines) +- if out.startswith('Apple LLVM'): ++ if out.startswith('Apple LLVM') or mesonlib.for_darwin(want_cross, self): + return ClangObjCCompiler(ccache + compiler, version, CompilerType.CLANG_OSX, is_cross, exe_wrap) + if out.startswith('clang'): + return ClangObjCCompiler(ccache + compiler, version, CompilerType.CLANG_STANDARD, is_cross, exe_wrap) +@@ -822,7 +822,7 @@ + compiler_type = self.get_gnu_compiler_type(defines) + version = self.get_gnu_version_from_defines(defines) + return GnuObjCPPCompiler(ccache + compiler, version, compiler_type, is_cross, exe_wrap, defines) +- if out.startswith('Apple LLVM'): ++ if out.startswith('Apple LLVM') or mesonlib.for_darwin(want_cross, self): + return ClangObjCPPCompiler(ccache + compiler, version, CompilerType.CLANG_OSX, is_cross, exe_wrap) + if out.startswith('clang'): + return ClangObjCPPCompiler(ccache + compiler, version, CompilerType.CLANG_STANDARD, is_cross, exe_wrap) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e7edea7740d7..d65dfadb8263 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -419,7 +419,7 @@ in findXMLCatalogs = makeSetupHook { } ../build-support/setup-hooks/find-xml-catalogs.sh; wrapGAppsHook = makeSetupHook { - deps = [ gnome3.dconf.lib gnome3.gtk librsvg makeWrapper ]; + deps = lib.optional (!stdenv.isDarwin) gnome3.dconf.lib ++ [ gtk3 librsvg makeWrapper ]; } ../build-support/setup-hooks/wrap-gapps-hook.sh; separateDebugInfo = makeSetupHook { } ../build-support/setup-hooks/separate-debug-info.sh;