Write key:value using lib.hm.gvariant for home-manager

Finally figured it out. The clue was here on this page, on the last part (or more specifically the last line) of the section.

So after some tries, I did this:

"org/gnome/shell/extensions/gestureImprovements" = {
  forward-back-application-keyboard-shortcuts=[
    (lib.hm.gvariant.mkDictionaryEntry["firefox.desktop" (lib.hm.gvariant.mkTuple[5 true])])
    (lib.hm.gvariant.mkDictionaryEntry["org.gnome.TextEditor.desktop" (lib.hm.gvariant.mkTuple[5 true])])
    (lib.hm.gvariant.mkDictionaryEntry["org.gnome.Nautilus.desktop" (lib.hm.gvariant.mkTuple[1 true])])
    (lib.hm.gvariant.mkDictionaryEntry["org.gnome.Console.desktop" (lib.hm.gvariant.mkTuple[5 true])])
  ];
};

And sure enough, it worked.

[org/gnome/shell/extensions/gestureImprovements]
forward-back-application-keyboard-shortcuts={'firefox.desktop': (5, true), 'org.gnome.TextEditor.desktop': (5, true), 'org.gnome.Nautilus.desktop': (1, true), 'org.gnome.Console.desktop': (5, true)}

PS: shorter version:

"org/gnome/shell/extensions/gestureImprovements" = {
  forward-back-application-keyboard-shortcuts = with lib.hm.gvariant; [ 
    (mkDictionaryEntry["firefox.desktop" (mkTuple[5 true])])
    (mkDictionaryEntry["org.gnome.TextEditor.desktop" (mkTuple[5 true])])
    (mkDictionaryEntry["org.gnome.Nautilus.desktop" (mkTuple[1 true])])
    (mkDictionaryEntry["org.gnome.Console.desktop" (mkTuple[5 true])])
  ];
};

PS2: Another example of multiple dictionaries in an array.

actual dconf:

[org/gnome/epiphany]
search-engine-providers=[{'url': <'https://www.bing.com/search?q=%s'>, 'bang': <'!b'>, 'name': <'Bing'>}, {'url': <'https://duckduckgo.com/?q=%s&t=epiphany'>, 'bang': <'!ddg'>, 'name': <'DuckDuckGo'>}, {'url': <'https://www.google.com/search?q=%s'>, 'bang': <'!g'>, 'name': <'Google'>}, {'url': <'https://www.startpage.com/search?q=%s'>, 'bang': <'!s'>, 'name': <'Startpage'>}]

Nix equivalent:

"org/gnome/epiphany" = {
  search-engine-providers = with lib.hm.gvariant; [
    [ 
      (mkDictionaryEntry["url" (mkVariant "https://www.bing.com/search?q=%s")])
      (mkDictionaryEntry["bang" (mkVariant "!b")])
      (mkDictionaryEntry["name" (mkVariant "Bing")])
    ]
    [ 
      (mkDictionaryEntry["url" (mkVariant "https://duckduckgo.com/?q=%s&t=epiphany")])
      (mkDictionaryEntry["bang" (mkVariant "!ddg")])
      (mkDictionaryEntry["name" (mkVariant "DuckDuckGo")])
    ]
    [ 
      (mkDictionaryEntry["url" (mkVariant "https://www.google.com/search?q=%s")])
      (mkDictionaryEntry["bang" (mkVariant "!g")])
      (mkDictionaryEntry["name" (mkVariant "Google")])
    ]
    [ 
      (mkDictionaryEntry["url" (mkVariant "https://www.startpage.com/search?q=%s")])
      (mkDictionaryEntry["bang" (mkVariant "!s")])
      (mkDictionaryEntry["name" (mkVariant "StartPage")])
    ]
  ];
};