In GNOME, you should use xkb-options
setting from the org.gnome.desktop.input-sources
GSettings schema.
See Strange xkbOptions behavior (GNOME) - #5 by jtojnar for an example how to set GSettings keys directly in a dconf database using NixOS option.
You can also set the value in the xserver config, since that is needed if you want to apply it to TTY with console.useXkbConfig
, and then refer to it within the dconf definitions similarly to how it is done here Setting caps lock as ctrl not working - #5 by jtojnar