Strange xkbOptions behavior (GNOME)

Hmm, if there is just the two languages, maybe there is split brain between X server and GNOME. I would probably avoid grp:alt_shift_toggle and configure the layout switching shortcut directly in GNOME.

And, for completeness, dconf databases also recently became configurable in NixOS so you do not need home-manager if you do not have multi-user system or all users use the same layouts (untested):

  services.xserver = {
    layout = "us,ru";
  };
  programs = {
    dconf = {
      profiles = {
        user = {
          databases = [
            {
              # Disallow changing the input settings in Control Center since unlike with NixOS options,
              # there is no merging between databases and user-db would just replace this.
              lockAll = true;
              settings = {
                "org/gnome/desktop/wm/keybindings" = {
                  switch-input-source = [ "<Alt>Tab" ];
                  switch-input-source-backward = [ "<Shift><Alt>Tab" ];
                };

                "org/gnome/desktop/input-sources" = {
                  sources = [
                    (lib.gvariant.mkTuple [
                      "xkb"
                      "us"
                    ])
                    (lib.gvariant.mkTuple [
                      "xkb"
                      "ru"
                    ])
                  ];
                };
              };
            }
          ];
        };
      };
    };
  };

Ideally, we would have option like console.useXkbConfig but it is tricky, see nixos/gnome/xkb-settings: init by jtojnar · Pull Request #257837 · NixOS/nixpkgs · GitHub.

1 Like