From 77c413926230eb4fda6be41f666f5603129bbf73 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Mon, 4 Apr 2016 18:06:48 +0900 Subject: [PATCH 1/3] gtk3: make gtk3 look for immodule cache in $NIX_PROFILE --- .../libraries/gtk+/3.0-immodules.cache.patch | 27 +++++++++++++++++++ pkgs/development/libraries/gtk+/3.x.nix | 9 ++----- 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 pkgs/development/libraries/gtk+/3.0-immodules.cache.patch diff --git a/pkgs/development/libraries/gtk+/3.0-immodules.cache.patch b/pkgs/development/libraries/gtk+/3.0-immodules.cache.patch new file mode 100644 index 000000000000..bbe5f28dbd3e --- /dev/null +++ b/pkgs/development/libraries/gtk+/3.0-immodules.cache.patch @@ -0,0 +1,27 @@ +--- a/gtk/deprecated/gtkrc.c 2016-04-02 18:43:08.401663112 +0900 ++++ b/gtk/deprecated/gtkrc.c 2016-04-02 18:29:19.927608592 +0900 +@@ -774,5 +774,23 @@ + if (var) + result = g_strdup (var); + ++ // check NIX_PROFILES paths. ++ const gchar *nixProfilesEnv = g_getenv ("NIX_PROFILES"); ++ gchar *cachePath; ++ guint i; ++ ++ if(nixProfilesEnv && !result){ ++ gchar **paths = g_strsplit(nixProfilesEnv, " ", -1); ++ for (i = 0; paths[i] != NULL; i++){ ++ cachePath = g_build_filename(paths[i], "etc", "gtk-3.0", "immodules.cache", NULL); ++ if( g_file_test( cachePath, G_FILE_TEST_EXISTS) ){ ++ if(result) g_free(result); ++ result = g_strdup(cachePath); ++ } ++ g_free(cachePath); ++ } ++ g_strfreev(paths); ++ } ++ + if (!result) + { + diff --git a/pkgs/development/libraries/gtk+/3.x.nix b/pkgs/development/libraries/gtk+/3.x.nix index a2da4c7b0339..45003e17f973 100644 --- a/pkgs/development/libraries/gtk+/3.x.nix +++ b/pkgs/development/libraries/gtk+/3.x.nix @@ -28,6 +28,8 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ pkgconfig gettext gobjectIntrospection perl ]; + patches = [ ./3.0-immodules.cache.patch ]; + buildInputs = [ libxkbcommon epoxy json_glib ]; propagatedBuildInputs = with xorg; with stdenv.lib; [ expat glib cairo pango gdk_pixbuf atk at_spi2_atk @@ -58,13 +60,6 @@ stdenv.mkDerivation rec { --replace '-L${gmp.dev}/lib' '-L${gmp.out}/lib' ''; - passthru = { - gtkExeEnvPostBuild = '' - rm $out/lib/gtk-3.0/3.0.0/immodules.cache - $out/bin/gtk-query-immodules-3.0 $out/lib/gtk-3.0/3.0.0/immodules/*.so > $out/lib/gtk-3.0/3.0.0/immodules.cache - ''; # workaround for bug of nix-mode for Emacs */ ''; - }; - meta = with stdenv.lib; { description = "A multi-platform toolkit for creating graphical user interfaces"; From 3e2318ec3ecff70e1583ad5717f26f91ecdda952 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Sat, 9 Apr 2016 17:43:55 +0900 Subject: [PATCH 2/3] gtk2: make gtk2 look for immodule cache in $NIX_PROFILE --- .../libraries/gtk+/2.0-immodules.cache.patch | 27 +++++++++++++++++++ pkgs/development/libraries/gtk+/2.x.nix | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 pkgs/development/libraries/gtk+/2.0-immodules.cache.patch diff --git a/pkgs/development/libraries/gtk+/2.0-immodules.cache.patch b/pkgs/development/libraries/gtk+/2.0-immodules.cache.patch new file mode 100644 index 000000000000..1b8231756e71 --- /dev/null +++ b/pkgs/development/libraries/gtk+/2.0-immodules.cache.patch @@ -0,0 +1,27 @@ +--- a/gtk/gtkrc.c 2014-09-30 05:02:17.000000000 +0900 ++++ b/gtk/gtkrc.c 2016-04-09 17:39:51.363288355 +0900 +@@ -445,5 +445,23 @@ + if (var) + result = g_strdup (var); + ++ // check NIX_PROFILES paths. ++ const gchar *nixProfilesEnv = g_getenv ("NIX_PROFILES"); ++ gchar *cachePath; ++ guint i; ++ ++ if(nixProfilesEnv && !result){ ++ gchar **paths = g_strsplit(nixProfilesEnv, " ", -1); ++ for (i = 0; paths[i] != NULL; i++){ ++ cachePath = g_build_filename(paths[i], "etc", "gtk-2.0", "immodules.cache", NULL); ++ if( g_file_test( cachePath, G_FILE_TEST_EXISTS) ){ ++ if(result) g_free(result); ++ result = g_strdup(cachePath); ++ } ++ g_free(cachePath); ++ } ++ g_strfreev(paths); ++ } ++ + if (!result) + { + diff --git a/pkgs/development/libraries/gtk+/2.x.nix b/pkgs/development/libraries/gtk+/2.x.nix index d4d4cddb4023..f3ebc189cd7a 100644 --- a/pkgs/development/libraries/gtk+/2.x.nix +++ b/pkgs/development/libraries/gtk+/2.x.nix @@ -26,6 +26,8 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ setupHook perl pkgconfig gettext ]; + patches = [ ./2.0-immodules.cache.patch ]; + propagatedBuildInputs = with xorg; with stdenv.lib; [ glib cairo pango gdk_pixbuf atk ] ++ optionals (stdenv.isLinux || stdenv.isDarwin) [ From cfe062f2b6e3c75a68f69104a1f87180004f1341 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Mon, 4 Apr 2016 18:11:20 +0900 Subject: [PATCH 3/3] input methods: fix gtk cache --- nixos/modules/config/system-path.nix | 2 + nixos/modules/i18n/input-method/default.nix | 42 +++++++++++++++++++-- nixos/modules/i18n/input-method/fcitx.nix | 2 +- nixos/modules/i18n/input-method/ibus.nix | 4 +- nixos/modules/i18n/input-method/nabi.nix | 2 +- nixos/modules/i18n/input-method/uim.nix | 2 +- 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index d7815324c4c4..8c4170597826 100644 --- a/nixos/modules/config/system-path.nix +++ b/nixos/modules/config/system-path.nix @@ -102,6 +102,8 @@ in environment.pathsToLink = [ "/bin" "/etc/xdg" + "/etc/gtk-2.0" + "/etc/gtk-3.0" "/info" "/lib" # FIXME: remove and update debug-info.nix "/sbin" diff --git a/nixos/modules/i18n/input-method/default.nix b/nixos/modules/i18n/input-method/default.nix index 7e6a25bfb084..5d57a7f99666 100644 --- a/nixos/modules/i18n/input-method/default.nix +++ b/nixos/modules/i18n/input-method/default.nix @@ -1,10 +1,32 @@ { config, pkgs, lib, ... }: with lib; - +let + cfg = config.i18n.inputMethod; + gtk2_cache = pkgs.stdenv.mkDerivation { + preferLocalBuild = true; + allowSubstitutes = false; + name = "gtk2-immodule.cache"; + buildInputs = [ pkgs.gtk cfg.package ]; + buildCommand = '' + mkdir -p $out/etc/gtk-2.0/ + GTK_PATH=${cfg.package}/lib/gtk-2.0/ gtk-query-immodules-2.0 > $out/etc/gtk-2.0/immodules.cache + ''; + }; + gtk3_cache = pkgs.stdenv.mkDerivation { + preferLocalBuild = true; + allowSubstitutes = false; + name = "gtk3-immodule.cache"; + buildInputs = [ pkgs.gtk3 cfg.package ]; + buildCommand = '' + mkdir -p $out/etc/gtk-3.0/ + GTK_PATH=${cfg.package}/lib/gtk-3.0/ gtk-query-immodules-3.0 > $out/etc/gtk-3.0/immodules.cache + ''; + }; +in { - options = { - i18n.inputMethod = { + options.i18n = { + inputMethod = { enabled = mkOption { type = types.nullOr (types.enum [ "ibus" "fcitx" "nabi" "uim" ]); default = null; @@ -24,6 +46,20 @@ with lib; ''; }; + + package = mkOption { + internal = true; + type = types.path; + default = null; + description = '' + The input method method package. + ''; + }; }; }; + + config = mkIf (cfg.enabled != null) { + environment.systemPackages = [ cfg.package gtk2_cache gtk3_cache ]; + }; + } diff --git a/nixos/modules/i18n/input-method/fcitx.nix b/nixos/modules/i18n/input-method/fcitx.nix index 8e31743504f1..bdefd2d2d596 100644 --- a/nixos/modules/i18n/input-method/fcitx.nix +++ b/nixos/modules/i18n/input-method/fcitx.nix @@ -32,7 +32,7 @@ in }; config = mkIf (config.i18n.inputMethod.enabled == "fcitx") { - environment.systemPackages = [ fcitxPackage ]; + i18n.inputMethod.package = fcitxPackage; environment.variables = { GTK_IM_MODULE = "fcitx"; diff --git a/nixos/modules/i18n/input-method/ibus.nix b/nixos/modules/i18n/input-method/ibus.nix index bb80f43634d3..097a662c3c6d 100644 --- a/nixos/modules/i18n/input-method/ibus.nix +++ b/nixos/modules/i18n/input-method/ibus.nix @@ -41,9 +41,11 @@ in }; config = mkIf (config.i18n.inputMethod.enabled == "ibus") { + i18n.inputMethod.package = ibusPackage; + # Without dconf enabled it is impossible to use IBus environment.systemPackages = with pkgs; [ - ibusPackage ibus-qt gnome3.dconf ibusAutostart + ibus-qt gnome3.dconf ibusAutostart ]; environment.variables = { diff --git a/nixos/modules/i18n/input-method/nabi.nix b/nixos/modules/i18n/input-method/nabi.nix index c6708365effa..87620ae4e7b2 100644 --- a/nixos/modules/i18n/input-method/nabi.nix +++ b/nixos/modules/i18n/input-method/nabi.nix @@ -3,7 +3,7 @@ with lib; { config = mkIf (config.i18n.inputMethod.enabled == "nabi") { - environment.systemPackages = [ pkgs.nabi ]; + i18n.inputMethod.package = pkgs.nabi; environment.variables = { GTK_IM_MODULE = "nabi"; diff --git a/nixos/modules/i18n/input-method/uim.nix b/nixos/modules/i18n/input-method/uim.nix index f8a3e560656d..7ad68bf851fe 100644 --- a/nixos/modules/i18n/input-method/uim.nix +++ b/nixos/modules/i18n/input-method/uim.nix @@ -22,7 +22,7 @@ in }; config = mkIf (config.i18n.inputMethod.enabled == "uim") { - environment.systemPackages = [ pkgs.uim ]; + i18n.inputMethod.package = pkgs.uim; environment.variables = { GTK_IM_MODULE = "uim";