Dead keys on gnome (UK keyboard)

Hi everyone,
Does anyone know how to enable dead keys on a UK keyboard? My confuguration is:

services.xserver = {
  layout = "gb";
  xkbVariant = "";
};
# Configure console keymap
console.keyMap = "uk";

Thank you :slight_smile:
Davide

I assume you want a UK layout that includes dead keys. In that case, in the Keyboard pane of GNOME Settings, add English (UK, intl., with dead keys) to Input Sources. Then, check what it did to your system settings. You will learn that xkbVariant (the part after the plus) is intl:

$ dconf read /org/gnome/desktop/input-sources/sources 
[…, ('xkb', 'gb+intl')]

Note that changing services.xserver.layout will not affect GNOME Shell since it only uses the X server option on first log-in and then uses the GSettings data stored in the dconf database. If you want to changes to take effect, you will need to reset the relevant settings and re-log in. Or, if you use home-manager, you can do something like this to always keep the GNOME settings in sync with the XKB ones from your NixOS configuration.

By the way instead of manually setting console.keyMap, you can use console.useXkbConfig = true; to inherit the service.xserver.layout in the console.

in the Keyboard pane of GNOME Settings, add English (UK, intl., with dead keys) to Input Sources

I have this option on my ubuntu distro, but not on my nixos

That is super weird. Can you share the screenshots of your Control Center? For example, this is what I have:


It’s in Italian, but should be understandable: Inglese = English; Regno Unito = United Kingdom
Schermata del 2022-09-05 11-37-35
Schermata del 2022-09-05 11-37-25
Schermata del 2022-09-05 11-37-12
Schermata del 2022-09-05 11-36-53

What do you see if you click on Inglese (Regno Unito)?

Also, you should be able to get the list of supported English layouts by running the following command:

env XDG_DATA_DIRS= GI_TYPELIB_PATH= nix-shell -p glib gdk-pixbuf gnome-desktop gobject-introspection 'python3.withPackages(ps: with ps; [ pygobject3 ])' --run 'python3 -c "from gi.repository import GnomeDesktop; i = GnomeDesktop.XkbInfo(); print(i.get_layouts_for_language(\"en\"))"'

Oops that opens a further window with many options, including the uk intl with dead keys - sorry I did not realize that! Setting that keyword and relogging makes gnome and the terminal work with the right keyboard.

Just a couple of things I do not get. First, I get:

dconf read /org/gnome/desktop/input-sources/sources
[('xkb', 'gb+intl')]

but if I set services.xserver.layout="gb+intl"; in my configuration I get an error:

The value `gb+intl' for keyboard layout is invalid.

Then, what does services.xserver actually do? It does provide gnome a configuration, which then is overridden by the GSettings? And what does console.keymap do?

You need to use

layout = "gb";
xkbVariant = "intl";

The X server module does many things but mainly configures X server.

GNOME desktop environment does consult the X server configuration in some cases but since X is only one of the supported backends, GNOME uses their own configuration.

Confusingly, the NixOS module for GNOME Shell and modules for other desktop environments also use the services.xserver prefix for their NixOS options (even when they default to Wayland nowadays). We just need to settle on a new name: create a graphical configuration module which is enabled when wayland and or xserver is enabled · Issue #139984 · NixOS/nixpkgs · GitHub

That is for the ttyX consoles you get into if you press Ctrl-Alt-F1 through F7 or when your graphical desktop environment does not start.

2 Likes