From cfe062f2b6e3c75a68f69104a1f87180004f1341 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Mon, 4 Apr 2016 18:11:20 +0900 Subject: 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(-) (limited to 'nixos') diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index d7815324c4c..8c417059782 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 7e6a25bfb08..5d57a7f9966 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 8e31743504f..bdefd2d2d59 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 bb80f43634d..097a662c3c6 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 c6708365eff..87620ae4e7b 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 f8a3e560656..7ad68bf851f 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"; -- cgit 1.4.1