From 1771f3a821490c2e0ded1bfff948b591c18ed7e6 Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Mon, 2 Jun 2025 11:20:04 +0200 Subject: [PATCH 1/3] ibus: modernize --- pkgs/tools/inputmethods/ibus/default.nix | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/pkgs/tools/inputmethods/ibus/default.nix b/pkgs/tools/inputmethods/ibus/default.nix index f951be91af29..e2b911810c7b 100644 --- a/pkgs/tools/inputmethods/ibus/default.nix +++ b/pkgs/tools/inputmethods/ibus/default.nix @@ -36,6 +36,8 @@ buildPackages, runtimeShell, nixosTests, + versionCheckHook, + nix-update-script, }: let @@ -61,14 +63,14 @@ let ''; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "ibus"; version = "1.5.32"; src = fetchFromGitHub { owner = "ibus"; repo = "ibus"; - tag = version; + tag = finalAttrs.version; hash = "sha256-Rp2Aw2C2LXMBp8++pnZtPHiPoFDERpkDsKd0E//twuY="; }; @@ -181,12 +183,14 @@ stdenv.mkDerivation rec { ]; enableParallelBuilding = true; + strictDeps = true; doCheck = false; # requires X11 daemon + doInstallCheck = true; - installCheckPhase = '' - $out/bin/ibus version - ''; + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgramArg = "version"; + versionCheckProgram = "${placeholder "out"}/bin/ibus"; postInstall = '' # It has some hardcoded FHS paths and also we do not use it @@ -205,13 +209,15 @@ stdenv.mkDerivation rec { tests = { installed-tests = nixosTests.installed-tests.ibus; }; + updateScript = nix-update-script { }; }; - meta = with lib; { + meta = { + changelog = "https://github.com/ibus/ibus/releases/tag/${finalAttrs.src.tag}"; homepage = "https://github.com/ibus/ibus"; description = "Intelligent Input Bus, input method framework"; - license = licenses.lgpl21Plus; - platforms = platforms.linux; - maintainers = with maintainers; [ ttuegel ]; + license = lib.licenses.lgpl21Plus; + platforms = lib.platforms.linux; + maintainers = with lib.maintainers; [ ttuegel ]; }; -} +}) From 8b825b220a969c42a4d6e00927e8022c49dd7640 Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Mon, 2 Jun 2025 14:14:13 +0200 Subject: [PATCH 2/3] ibus: split into 'ibus' and 'ibusMinimal' Motivation: `ibus` carries lots of dependencies on various versions of gtk. These dependencies become transitive dependencies for sdl3, which causes quite expensive compiles in the sdl3 closure. Particularly, this means gtk (and, in turn, gstreamer and everything else) become part of e.g. ffmpeg. `sdl3` itself uses ibus almost exclusively via dbus, and reimplements some of the most important features. It does depend on ibus only to use some of the constants defined in headers. It does not actually load ibus libraries. This means, as long as the headers are identical, all the gtk dependencies can be removed in the ibus for sdl3. This requires this split. --- pkgs/by-name/ib/ibusMinimal/package.nix | 1 + pkgs/tools/inputmethods/ibus/default.nix | 96 ++++++++++++++---------- 2 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 pkgs/by-name/ib/ibusMinimal/package.nix diff --git a/pkgs/by-name/ib/ibusMinimal/package.nix b/pkgs/by-name/ib/ibusMinimal/package.nix new file mode 100644 index 000000000000..a828d049c66e --- /dev/null +++ b/pkgs/by-name/ib/ibusMinimal/package.nix @@ -0,0 +1 @@ +{ ibus }: ibus.override { libOnly = true; } diff --git a/pkgs/tools/inputmethods/ibus/default.nix b/pkgs/tools/inputmethods/ibus/default.nix index e2b911810c7b..6c47a6b6e441 100644 --- a/pkgs/tools/inputmethods/ibus/default.nix +++ b/pkgs/tools/inputmethods/ibus/default.nix @@ -27,8 +27,8 @@ python3, json-glib, libnotify ? null, - enableUI ? true, - withWayland ? true, + enableUI ? !libOnly, + withWayland ? !libOnly, libxkbcommon, wayland, wayland-protocols, @@ -38,6 +38,8 @@ nixosTests, versionCheckHook, nix-update-script, + libX11, + libOnly ? false, }: let @@ -88,11 +90,14 @@ stdenv.mkDerivation (finalAttrs: { ./build-without-dbus-launch.patch ]; - outputs = [ - "out" - "dev" - "installedTests" - ]; + outputs = + [ + "out" + "dev" + ] + ++ lib.optionals (!libOnly) [ + "installedTests" + ]; postPatch = '' # Maintainer does not want to create separate tarballs for final release candidate and release versions, @@ -109,29 +114,38 @@ stdenv.mkDerivation (finalAttrs: { preAutoreconf = "touch ChangeLog"; - configureFlags = [ - # The `AX_PROG_{CC,CXX}_FOR_BUILD` autoconf macros can pick up unwrapped GCC binaries, - # so we set `{CC,CXX}_FOR_BUILD` to override that behavior. - # https://github.com/NixOS/nixpkgs/issues/21751 - "CC_FOR_BUILD=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc" - "CXX_FOR_BUILD=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++" - "GLIB_COMPILE_RESOURCES=${lib.getDev buildPackages.glib}/bin/glib-compile-resources" - "PKG_CONFIG_VAPIGEN_VAPIGEN=${lib.getBin buildPackages.vala}/bin/vapigen" - "--disable-memconf" - (lib.enableFeature (dconf != null) "dconf") - (lib.enableFeature (libnotify != null) "libnotify") - (lib.enableFeature withWayland "wayland") - (lib.enableFeature enableUI "ui") - "--disable-gtk2" - "--enable-gtk4" - "--enable-install-tests" - "--with-unicode-emoji-dir=${unicode-emoji}/share/unicode/emoji" - "--with-emoji-annotation-dir=${cldr-annotations}/share/unicode/cldr/common/annotations" - "--with-python=${python3BuildEnv.interpreter}" - "--with-ucd-dir=${unicode-character-database}/share/unicode" - ]; + configureFlags = + [ + # The `AX_PROG_{CC,CXX}_FOR_BUILD` autoconf macros can pick up unwrapped GCC binaries, + # so we set `{CC,CXX}_FOR_BUILD` to override that behavior. + # https://github.com/NixOS/nixpkgs/issues/21751 + "CC_FOR_BUILD=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}cc" + "CXX_FOR_BUILD=${buildPackages.stdenv.cc}/bin/${buildPackages.stdenv.cc.targetPrefix}c++" + "GLIB_COMPILE_RESOURCES=${lib.getDev buildPackages.glib}/bin/glib-compile-resources" + "PKG_CONFIG_VAPIGEN_VAPIGEN=${lib.getBin buildPackages.vala}/bin/vapigen" + "--disable-memconf" + "--disable-gtk2" + "--with-python=${python3BuildEnv.interpreter}" + (lib.enableFeature (!libOnly && dconf != null) "dconf") + (lib.enableFeature (!libOnly && libnotify != null) "libnotify") + (lib.enableFeature withWayland "wayland") + (lib.enableFeature enableUI "ui") + (lib.enableFeature (!libOnly) "gtk3") + (lib.enableFeature (!libOnly) "gtk4") + (lib.enableFeature (!libOnly) "xim") + (lib.enableFeature (!libOnly) "appindicator") + (lib.enableFeature (!libOnly) "tests") + (lib.enableFeature (!libOnly) "install-tests") + (lib.enableFeature (!libOnly) "emoji-dict") + (lib.enableFeature (!libOnly) "unicode-dict") + ] + ++ lib.optionals (!libOnly) [ + "--with-unicode-emoji-dir=${unicode-emoji}/share/unicode/emoji" + "--with-emoji-annotation-dir=${cldr-annotations}/share/unicode/cldr/common/annotations" + "--with-ucd-dir=${unicode-character-database}/share/unicode" + ]; - makeFlags = [ + makeFlags = lib.optionals (!libOnly) [ "test_execsdir=${placeholder "installedTests"}/libexec/installed-tests/ibus" "test_sourcesdir=${placeholder "installedTests"}/share/installed-tests/ibus" ]; @@ -148,11 +162,14 @@ stdenv.mkDerivation (finalAttrs: { makeWrapper pkg-config python3BuildEnv - vala - wrapGAppsHook3 dbus-launch + glib # required to satisfy AM_PATH_GLIB_2_0 + vala gobject-introspection ] + ++ lib.optionals (!libOnly) [ + wrapGAppsHook3 + ] ++ lib.optionals withWayland [ wayland-scanner ]; @@ -166,14 +183,17 @@ stdenv.mkDerivation (finalAttrs: { dbus systemd dconf - gdk-pixbuf python3.pkgs.pygobject3 # for pygobject overrides - gtk3 - gtk4 isocodes json-glib - libnotify + libX11 + ] + ++ lib.optionals (!libOnly) [ + gtk3 + gtk4 + gdk-pixbuf libdbusmenu-gtk3 + libnotify vala # for share/vala/Makefile.vapigen (PKG_CONFIG_VAPIGEN_VAPIGEN) ] ++ lib.optionals withWayland [ @@ -192,13 +212,13 @@ stdenv.mkDerivation (finalAttrs: { versionCheckProgramArg = "version"; versionCheckProgram = "${placeholder "out"}/bin/ibus"; - postInstall = '' + postInstall = lib.optionalString (!libOnly) '' # It has some hardcoded FHS paths and also we do not use it # since we set up the environment in NixOS tests anyway. moveToOutput "bin/ibus-desktop-testing-runner" "$installedTests" ''; - postFixup = '' + postFixup = lib.optionalString (!libOnly) '' # set necessary environment also for tests for f in $installedTests/libexec/installed-tests/ibus/*; do wrapGApp $f @@ -206,7 +226,7 @@ stdenv.mkDerivation (finalAttrs: { ''; passthru = { - tests = { + tests = lib.optionalAttrs (!libOnly) { installed-tests = nixosTests.installed-tests.ibus; }; updateScript = nix-update-script { }; From 2533354092d77947beb41b5836a7926e0b4d89ad Mon Sep 17 00:00:00 2001 From: Grimmauld Date: Mon, 2 Jun 2025 14:23:13 +0200 Subject: [PATCH 3/3] sdl3: build against 'ibusMinimal' `sdl3` only relies on constant definitions in the ibus headers, which does not require ibus to be compiled with gtk support. This means we can shrink the unnecessarily large closure. --- pkgs/by-name/sd/sdl3/package.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/sd/sdl3/package.nix b/pkgs/by-name/sd/sdl3/package.nix index 604a9427541a..1519f837e911 100644 --- a/pkgs/by-name/sd/sdl3/package.nix +++ b/pkgs/by-name/sd/sdl3/package.nix @@ -8,7 +8,7 @@ darwinMinVersionHook, dbus, fetchFromGitHub, - ibus, + ibusMinimal, installShellFiles, libGL, libayatana-appindicator, @@ -104,7 +104,11 @@ stdenv.mkDerivation (finalAttrs: { apple-sdk_11 ] ++ lib.optionals ibusSupport [ - ibus + # sdl3 only uses some constants of the ibus headers + # it never actually loads the library + # thus, it also does not have to care about gtk integration, + # so using ibusMinimal avoids an unnecessarily large closure here. + ibusMinimal ] ++ lib.optional waylandSupport zenity;