How to use keyboard with english variant that has accents?

So far I like what I see in NixOS, however, since I’ve been using I didn’t find how to change my keyboard layout to allow accents. I’m from Brazil, but my laptop is from US, and it has accents, e.g:

e + Alt + 6 (^) = ê
e + e = é

I’ve been looking all around, including the official documentation. So far, no lucky. I’ve also played with the following variables:

  services.xserver.layout = "us";
  services.xserver.xkbVariant = "intl";

ANY help is appreciate. I’m starting to get really frustrated about this :confused:

1 Like

What keyboard layout/variants do you choose on other linuxes or Windows?

Though what is wrong with br or pt base layout?

I’m a spanish speaker and was learning french in the past, but I program listen and write in english most of the day

I use services.xserver.xkbVariant = "altgr-intl";

This enables accents with the right alt key: éėêèñ
keeps US layout as principal (good for programming)
and is 1 key away of spanish/french accents

altgr+6 then e = ê
altgr+e = é
altgr+' then e = é
altgr+` then e = è

This is my NixOS user interface config:
in case it helps

1 Like

That’s exactly the layout I used in my Arch, but when I define in NisOX, it doesn’t change anything. Do I have to run anything besides sudo nixos-rebuild switch? Sorry if this is obvious. I’m still going through the docs.

Maybe try rebooting? or restarting the xserver (not sure how to restart it)

Do you have services.xserver.enable = true; ?

Also notice that intl and altgr-intl are different, I’m not sure if intl is actually recognized by xserver, but I’m sure altgr-intl is a valid value

I also do services.xserver.exportConfiguration = true; so I can see the final config somewhere in /etc and debug

I do. My entire xserver configuration is in the main config file (/etc/nixos/configuration.nix). The relevant part for this is:

  # Enable the X11 windowing system.
  services.xserver.enable = true;
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  services.xserver.layout = "us";
  services.xserver.xkbVariant = "altgr-intl";
  services.xserver.exportConfiguration = true; 

I tried to reboot, but no lucky :confused:.

My layout is not br or pt. In my arch I was using altgr-intl (layout here), however it didn’t work.

As you are using Gnome, it might be that it has its own means of configuration for the keyboard and many other things, it might ignore what you set through X.

Can you run setxkbmap -query before and after setxkbmap us altgr-intl?

Does it change anything? Is perhaps the layout and variant properly set, but Gnome ignores them? In that case you might need to change it manually for Gnome.


rules:      evdev
model:      pc104
layout:     us,us
variant:    ,
options:    eurosign:e


rules:      evdev
model:      pc104
layout:     us
variant:    altgr-intl
options:    eurosign:e

It works now. I thought NixOS would work with Gnome.

There are things that nix can not change after the fact, this is usually the fault of the program not rereading config files or not reading events properly, or simply not adjusting internal state accordingly.

Especially DEs usually assume that everything is under their controll, and therefore refuse to adhere to external impulses/changes.

NixOS works with Gnome,

what I used before switching to i3, was configuring things as I liked it by hand, and then run: to generate the dconf configuration automatically. Then home-manager loads it into dconf (the configuration engine of Gnome)

This is my NixOS configuration back then, the keyboard is just doing this:

For GNOME, see Problem with `xkbOptions` - it doesn't seem to take effect - #2 by jtojnar