Jump to content

GNOME: Difference between revisions

From NixOS Wiki
Nicdumz (talk | contribs)
m Systray Icons: gnome-settings-daemon was move to top-level
Jasi (talk | contribs)
m GNOME desktop: fix typo
 
(54 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[[{{PAGENAME}}]] (/(ɡ)noʊm/) is a [[:Category:Desktop environment|desktop environment]] known for its focus on being simple, intuitive, and easy to use. It is made by The GNOME Project and is composed entirely of free and open-source software. Its Mutter compositor supports both [[Wayland]] and X server, and the GNOME Shell user interface is customizable by extensions.
[[{{PAGENAME}}]] (/(ɡ)noʊm/) is a [[:Category:Desktop environment|desktop environment]] that seeks to be "an independent computing platform for everyone."<ref>Official GNOME Project one-liner https://www.gnome.org/ </ref>


This article is an extension of the documentation in the [https://nixos.org/manual/nixos/stable/#chap-gnome NixOS manual].
This article is an extension of the documentation in the [https://nixos.org/manual/nixos/stable/#chap-gnome NixOS manual].


[https://gnome.org/ {{PAGENAME}}] is available as a [[module]] and can be enabled with <code>services.xserver.desktopManager</code>.
== Installation ==


== Installation ==
=== GNOME desktop ===
To use the GNOME desktop environment on NixOS, the following configuration options must be set:


To use GNOME, add this to your <code>configuration.nix</code>:
{{file|3={ config, pkgs, ... }:


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
{
  # Pre 25.11
   services.xserver.enable = true;
   services.xserver.enable = true;
   services.xserver.displayManager.gdm.enable = true;
   services.xserver.displayManager.gdm.enable = true;
   services.xserver.desktopManager.gnome.enable = true;
   services.xserver.desktopManager.gnome.enable = true;
}
</nowiki>}}


=== Excluding GNOME Applications ===
  # As of 25.11
  services.displayManager.gdm.enable = true;
  services.desktopManager.gnome.enable = true;
 
  # To disable installing GNOME's suite of applications
  # and only be left with GNOME shell.
  services.gnome.core-apps.enable = false;
  services.gnome.core-developer-tools.enable = false;
  services.gnome.games.enable = false;
  environment.gnome.excludePackages = with pkgs; [ gnome-tour gnome-user-docs ];
 
}|name=/etc/nixos/configuration.nix|lang=nix}}
 
Despite the options in NixOS versions before 25.11 being under the <code>xserver</code> module, GNOME uses [[Wayland]] by default. NixOS 25.11 and later removes support for the [[Xorg]] session entirely (though Xwayland is still included and supported for compatibility).
 
=== GNOME extensions ===
GNOME offers support for changing/overhauling the user interface (GNOME Shell) through the use of ''[https://extensions.gnome.org/about/ Extensions].'' Extensions are bundles of third-party [https://gjs.guide/extensions/ GJS] modules that are loaded while GNOME is running to augment the user experience. A repository of GNOME extensions can be found on GNOME's official [https://extensions.gnome.org/ webpage] and can be installed imperatively if needed by unpacking the extension in <code>~/.local/share/gnome-shell/extensions</code> directory. Extensions can only be activated if it supports the GNOME release that it's installed alongside with.


To exclude certain applications that are installed by default with GNOME edit <code>configuration.nix</code> as follows:
In addition, NixOS automatically packages all officially available GNOME extensions under the <code>pkgs.gnomeExtensions</code> attribute. Extensions which require additional dependencies are then manually packaged if needed. Installed extensions can be enabled graphically through the built-in "Extensions" application or through the <code>gnome-extensions</code> command line interface.


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|3={
{
   environment.systemPackages = with pkgs; [
   environment.gnome.excludePackages = with pkgs; [
     gnomeExtensions.blur-my-shell
     orca
     gnomeExtensions.just-perfection
    evince
     gnomeExtensions.arc-menu
    # file-roller
    geary
    gnome-disk-utility
    # seahorse
    # sushi
    # sysprof
    #
    # gnome-shell-extensions
    #
     # adwaita-icon-theme
    # nixos-background-info
    gnome-backgrounds
    # gnome-bluetooth
    # gnome-color-manager
    # gnome-control-center
    # gnome-shell-extensions
    gnome-tour # GNOME Shell detects the .desktop file on first log-in.
    gnome-user-docs
    # glib # for gsettings program
    # gnome-menus
    # gtk3.out # for gtk-launch program
     # xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/
    # xdg-user-dirs-gtk # Used to create the default bookmarks
    #
    baobab
    epiphany
    gnome-text-editor
    gnome-calculator
    gnome-calendar
    gnome-characters
    # gnome-clocks
    gnome-console
    gnome-contacts
    gnome-font-viewer
    gnome-logs
    gnome-maps
    gnome-music
    # gnome-system-monitor
    gnome-weather
    # loupe
    # nautilus
    gnome-connections
    simple-scan
    snapshot
    totem
    yelp
    gnome-software
   ];
   ];
}
}|name=/etc/nixos/configuration.nix|lang=nix}}
</nowiki>}}
== Configuration ==
 
=== dconf ===
 
Dconf is a low-level configuration system for storing and loading configurations. The dconf database is stored in a single binary file in <code>~/.config/dconf/user</code> and contains all known configuration values for all applications and programs that use dconf (GNOME applications and shell, gtk, etc).


== Configuration ==
For example, the setting which controls the accent color of GNOME shell is located in the ''schema'' labeled <code>/org/gnome/desktop/interface/</code> which contains the ''key'' <code>accent-color</code> which accepts a GVariant ''value'' of type <code>enum</code> (one of <code>'blue'</code>, <code>'teal'</code>, <code>'green'</code>, etc)


=== Managing extensions ===
NixOS and Home Manager both provide an interface for declarative configuration of dconf settings exposed in <code>programs.dconf</code> and <code>dconf</code> modules respectively.


GNOME extensions are managed and configured by the program "Extensions" that comes with GNOME. Some of them can be installed with Nix, however they aren't enabled by default. To enable them the "Extensions" program can be used.
Going back to the previous example, to set the accent color of GNOME in a declarative manner in NixOS as well as mapping the keyboard's "caps lock" key to "ctrl" you would write:


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|3={
{
   programs.dconf.profiles.user.databases = [
   environment.systemPackages = with pkgs.gnomeExtensions; [
     {
     blur-my-shell
      lockAll = true; # prevents overriding
    pop-shell
      settings = {
     # ...
        "org/gnome/desktop/interface" = {
          accent-color = "blue";
        };
        "org/gnome/desktop/input-sources" = {
          xkb-options = [ "ctrl:nocaps" ];
        };
      };
     }
   ];
   ];
}
}|name=/etc/nixos/configuration.nix|lang=nix}}
</nowiki>}}
 
And the equivalent snippet in Home Manager:
 
{{file|3={
  dconf.enable = true;
  dconf.settings = {
    "org/gnome/desktop/interface" = {
      accent-color = "blue";
    };
    "org/gnome/desktop/input-sources" = {
      xkb-options = [ "ctrl:nocaps" ];
    };
  };
}|name=~/.config/home-manager/home.nix|lang=nix}}Thus the settings attribute accepts an attribute set whose keys are schemas with each schema's value being a nested attribute set of the schema's keys with their appropriate GVariant value.{{Note|Schemas in Nix are written without leading and trailing slashes. In addition, since dconf have more data types than the Nix language (for example, tuples), in some cases you'll need to convert Nix value to a GVariant value. You can achieve that by using the functions defined under <code>lib.gvariant</code>, they're documented [https://nixos.org/manual/nixpkgs/stable/#sec-functions-library-gvariant here].}}If you wish to revert all dconf settings back to their default state (reset GNOME essentially) then use the following command which  resets all schemas directories available on your system, note that this will affect all programs that use dconf, including GNOME apps and extensions.<syntaxhighlight lang="bash">
$ dconf reset -f /
</syntaxhighlight>
 
==== Extensions ====
Extensions are not activated by default when installed with Nix but can be configured to do so using the respective dconf modules. The schema is <code>/org/gnome/shell/</code> with the key <code>enabled-extensions</code> which accepts a list of strings that represent extension UUIDs. If the extension was installed with Nix, then the UUID can be accessed by the <code>extensionUuid</code> attribute of the extension itself. Each extension's configuration can then be found under their corresponding schema in <code>/org/gnome/shell/extensions/</code> and be configured as needed.


Installed extensions can be enabled and configured in Extension app that comes preinstalled with GNOME. If you want to do that declaratively in your configuration, you can use [[Home Manager]] <code>dconf</code> module by adding following lines.
For example, in Home Manager, you could write:


{{file|~/.config/home-manager/home.nix|nix|<nowiki>
{{file|3={
{
   dconf = {
   dconf = {
     enable = true;
     enable = true;
     settings = {
     settings = {
       "org/gnome/shell" = {
       "org/gnome/shell" = {
         disable-user-extensions = false; # enables user extensions
         # disable-user-extensions = true; # Optionally disable user extensions entirely
         enabled-extensions = [
         enabled-extensions = [
           # Put UUIDs of extensions that you want to enable here.
           # Put UUIDs of extensions that you want to enable here.
Line 108: Line 105:
           # field (look at the following example).
           # field (look at the following example).
           pkgs.gnomeExtensions.gsconnect.extensionUuid
           pkgs.gnomeExtensions.gsconnect.extensionUuid
         
 
           # Alternatively, you can manually pass UUID as a string.
           # Alternatively, you can manually pass UUID as a string.
           "blur-my-shell@aunetx"
           "blur-my-shell@aunetx"
           # ...
           # ...
Line 122: Line 119:
     };
     };
   };
   };
}
}|name=~/.config/home-manager/home.nix|lang=nix}}
</nowiki>}}


=== dconf settings ===
== Tips and tricks ==


Most of the GNOME settings are stored in [https://en.wikipedia.org/wiki/Dconf dconf] database. Settings are stored as keys placed in folders.
=== GNOME power user apps ===
Both GNOME Tweaks (accessible as <code>gnome-tweaks</code>) and [https://gitlab.gnome.org/TheEvilSkeleton/Refine Refine] (accessible as <code>refine</code>) allow you to change certain GNOME settings that are hidden by default (such as interface font, window decoration buttons like maximize/minimize, icon themes and GTK themes, etc).  


To learn about settings that can be configured with dconf either look into <code>dconf-editor</code> program (provided by <code>gnome.dconf-editor</code> package) or type <code>dconf watch /</code> in the terminal and change settings from the GUI and see which options are responsible for that component/element.
The GNOME shell extension [https://extensions.gnome.org/extension/3843/just-perfection/ Just Perfection] also allows for customizing nearly all parts of the GNOME shell interface.  


These settings can be changed by NixOS via <code>programs.dconf</code> module or by [[Home Manager]] via <code>dconf</code> module. To so in Home Manager, you need to change <code>dconf.settings</code> attribute set. This attribute set contains absolute folder paths (without leading slash) as attributes' names which value is another attribute set with keys (settings).
=== GNOME Qt integration ===
 
Using the following example configuration, Qt applications will have a look similar to the adwaita style used by GNOME using a dark theme.
For example, to change the value of <code>clock-show-weekday</code> key that is located in <code>/org/gnome/desktop/interface</code>, you need to the following:
{{File|3={
 
   qt = {
{{file|~/.config/home-manager/home.nix|nix|<nowiki>
{
   dconf.settings = {
     enable = true;
     enable = true;
 
     platformTheme = "gnome";
    # You need quotes to escape '/'
     style = "adwaita-dark";
     "org/gnome/desktop/interface" = {
      clock-show-weekday = true;
     };
   };
   };
}
}|name=/etc/nixos/configuration.nix|lang=nix}}
</nowiki>}}
For other themes, you may need the packages <code>libsForQt5.qt5ct</code> and <code>libsForQt5.qtstyleplugin-kvantum</code> and a symlink from <code>~/.config/Kvantum/</code> to your theme package. Here is an example using Arc-Dark and [[Home Manager]]. In the Home Manager configuration:
 
{{File|3={
Same can be achieved by using system configuration.
   qt = {
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
   programs.dconf = {
     enable = true;
     enable = true;
     profiles.user.databases = [
     platformTheme = "qtct";
      {
    style = "kvantum";
        lockAll = true; # prevents overriding
        settings = {
          "org/gnome/desktop/interface" = {
            clock-show-weekday = true;
          };
        };
      }
    ];
   };
   };
}
</nowiki>}}


{{Note|Since dconf have more data types than Nix language (for example, tuples), in some cases you'll need to convert Nix value to a GVariant value. You can achieve that by using function defined in <code>lib.gvariant</code>, they're documented [https://nixos.org/manual/nixpkgs/stable/#sec-functions-library-gvariant here].}}
  xdg.configFile = {
    "Kvantum/ArcDark".source = "${pkgs.arc-kde-theme}/share/Kvantum/ArcDark";
    "Kvantum/kvantum.kvconfig".text = "[General]\ntheme=ArcDark";
  };
}|name=~/.config/home-manager/home.nix|lang=nix}}
For more details, see [https://discourse.nixos.org/t/guide-to-installing-qt-theme/35523/2 this] forum post.{{Note|Qt integration with the adwaita style isn't perfect and your mileage may vary.}}


=== Dark mode ===
=== Experimental settings ===
GNOME has a number of experimental settings for features not fully completed and thus hidden from the user. As of GNOME 48, these are the experimental features you may want to use:
{{File|3={
  programs.dconf.profiles.user.databases = [
    {
      settings = {
        "org/gnome/mutter" = {
          experimental-features = [
            "scale-monitor-framebuffer" # Enables fractional scaling (125% 150% 175%)
            "variable-refresh-rate" # Enables Variable Refresh Rate (VRR) on compatible displays
            "xwayland-native-scaling" # Scales Xwayland applications to look crisp on HiDPI screens
          ];
        };
      };
    }
  ];
}|name=/etc/nixos/configuration.nix|lang=nix}}


Change default color theme for all GTK4 applications to dark using [[Home Manager]].
=== Discover dconf settings ===
If you wish to discover the corresponding dconf entry for a given setting in a program, you can run `dconf watch /` inside of a terminal and change the setting graphically. For example, when changing toggling the Quick-Settings option "Dark Style" from "on" to "off" and back to "on," this will be the output:<syntaxhighlight lang="shell-session">
$ dconf watch /
/org/gnome/desktop/interface/color-scheme
  'default'


{{file|~/.config/home-manager/home.nix|nix|<nowiki>
/org/gnome/desktop/interface/color-scheme
{
  'prefer-dark'
  dconf = {
</syntaxhighlight>Otherwise you can use the gsettings programs to inspect the schemas installed on your system. For example, to inspect all the keys contained within <code>/org/gnome/desktop/background</code> you could run:<syntaxhighlight lang="shell-session">
    enable = true;
$ gsettings list-keys org.gnome.desktop.background
    settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
color-shading-type
  };
picture-opacity
}
picture-options
</nowiki>}}
picture-uri
picture-uri-dark
primary-color
secondary-color
show-desktop-icons


== Tips and tricks ==
</syntaxhighlight>Then to see the range of possible values for one of the keys such as <code>picture-options</code> you could then run:<syntaxhighlight lang="shell-session">
$ gsettings range org.gnome.desktop.background picture-options
enum
'none'
'wallpaper'
'centered'
'scaled'
'stretched'
'zoom'
'spanned'


=== To run GNOME programs outside of GNOME ===


GNOME platform-based applications are largely [https://nixos.org/nixpkgs/manual/#sec-language-gnome self-contained], but they still depend, for one reason or another, on some global configuration. The {{ic|gnome.nix}} module sets all the necessary options for you but if you are running customized set-up, you might need to replicate that yourself.
</syntaxhighlight>Which tells you that the ''key'' <code>picture-options</code> located in ''schema'' <code>/org/gnome/desktop/background/</code> accepts a ''value'' of type enumeration (a single string value from a set of accepted values).  


For instance, if you see the following error:
=== Enable system tray icons ===
GNOME does not currently support system tray icons. However, Ubuntu has created an [https://extensions.gnome.org/extension/615/appindicator-support/ extension] that implements this in the top bar. You can install this extension with the following in NixOS:
{{File|3={
  environment.systemPackages = [ pkgs.gnomeExtensions.appindicator  ];
  services.udev.packages = [ pkgs.gnome-settings-daemon ];
}|name=/etc/nixos/configuration.nix|lang=nix}}


<syntaxhighlight lang="text">
=== Profiling (with sysprof) ===
dconf-WARNING **: failed to commit changes to dconf: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name ca.desrt.dconf was not provided by any .service files
</syntaxhighlight>


you should enable dconf module:
Install {{ic|sysprof}} as a ''system'' package (it won't work properly if installed against users). Then enable the associated service with
 
<syntaxHighlight lang="nix">
{
  programs.dconf.enable = true;
}
</syntaxHighlight>
 
Many applications rely heavily on having an icon theme available, GNOME’s Adwaita is a good choice but most recent icon themes should work as well.


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{
   services.sysprof.enable = true;
   environment.systemPackages = [ pkgs.adwaita-icon-theme ];
}
</syntaxhighlight>
</syntaxhighlight>


=== Systray Icons ===
=== Automatic screen rotation ===
 
To get systray icons, install the related GNOME shell extension
 
<syntaxHighlight lang="nix">
{
  environment.systemPackages = [ pkgs.gnomeExtensions.appindicator ];
}
</syntaxHighlight>
 
And ensure gnome-settings-daemon udev rules are enabled:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{
   hardware.sensor.iio.enable = true;
   services.udev.packages = [ pkgs.gnome-settings-daemon ];
}
</syntaxhighlight>
</syntaxhighlight>


=== To run old applications ===
=== Dark mode ===


Some old applications use GConf service to store configuration. This has been deprecated for many years but some applications were abandoned before they managed to upgrade to a newer dconf system. If you are running such application and getting an error like:
Change default color theme for all GTK4 applications to dark using [[Home Manager]].


<syntaxHighlight lang="text">
{{file|~/.config/home-manager/home.nix|nix|<nowiki>
GLib.GException: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information
</syntaxHighlight>
 
you need to add {{ic|gnome2.GConf}} to the list of dbus packages in your {{ic|configuration.nix}}:
 
<syntaxHighlight lang="nix">
{
{
   services.dbus.packages = with pkgs; [ gnome2.GConf ];
   dconf = {
    enable = true;
    settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
  };
}
}
</syntaxHighlight>
</nowiki>}}


After applying the update restart your desktop session to refresh the user-specific dbus session.
=== Excluding GNOME Applications ===
 
=== Dynamic triple buffering ===


{{Warning|Dynamic triple buffering is a still developing feature that is not merged into GNOME's mutter. Some bugs and unexpected behavior can occur. Use at your own risk!}}
To exclude certain applications that are installed by default with GNOME, set the {{nixos:option|environment.gnome.excludePackages}} module option (Optional Packages: [https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/desktop-managers/gnome.nix#L449-L471 gnome.nix]):
 
Big [https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441 merge request] against Mutter improves the performance of the window manager by a lot (and is already used by Ubuntu). Not merged into nixpkgs due to [https://github.com/NixOS/nixpkgs/issues/197181 philosophy of nixpkgs], but users are free to add this overlay to get it too.
 
If you wish to try this patch for yourself, add the following to your NixOS configuration:


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
   environment.gnome.excludePackages = with pkgs; [
   nixpkgs.overlays = [
     totem
    # GNOME 46: triple-buffering-v4-46
    (final: prev: {
      mutter = prev.mutter.overrideAttrs (old: {
        src = pkgs.fetchFromGitLab  {
          domain = "gitlab.gnome.org";
          owner = "vanvugt";
          repo = "mutter";
          rev = "triple-buffering-v4-46";
          hash = "sha256-C2VfW3ThPEZ37YkX7ejlyumLnWa9oij333d5c4yfZxc=";
        };
      });
     })
   ];
   ];
}
</nowiki>}}
</nowiki>}}


Prior to [https://github.com/NixOS/nixpkgs/commit/7f387d6bf915b8fd7d7131edd3e5107f4a98cc9d commit 7f387d6b] (~01.09.2024 for master) <code>mutter</code> was located in <code>gnome</code> scope, so <code>overrideScope</code> was required to achieve the same result:
== Troubleshooting ==
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  nixpkgs.overlays = [
    # GNOME 46: triple-buffering-v4-46
    (final: prev: {
      gnome = prev.gnome.overrideScope (gnomeFinal: gnomePrev: {
        mutter = gnomePrev.mutter.overrideAttrs (old: {
          src = pkgs.fetchFromGitLab  {
            domain = "gitlab.gnome.org";
            owner = "vanvugt";
            repo = "mutter";
            rev = "triple-buffering-v4-46";
            hash = "sha256-fkPjB/5DPBX06t7yj0Rb3UEuu5b9mu3aS+jhH18+lpI=";
          };
        });
      });
    })
  ];
}
</nowiki>}}


=== Missing cursor/cursor is a white box ===
This occurs when installing GNOME from an existing NixOS installation that used a different desktop environment that modified dconf (most likely switching from KDE to GNOME). To easily fix this: reset all dconf settings.<syntaxhighlight lang="bash">
$ dconf reset -f /
</syntaxhighlight>


You might need to disable aliases to make it work:
=== Running GConf-based applications ===


<syntaxHighlight lang="nix">
There exist very old applications which use the deprecated GConf service to store configuration. If you are running such an application and are getting an error like:
  nixpkgs.config.allowAliases = false;
</syntaxHighlight>'''NOTE''' - the "allowAliases" set to false has been known to break stylix (if you use it).


=== Profiling (with sysprof) ===
<syntaxhighlight lang="text">
GLib.GException: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information
</syntaxhighlight>


Install {{ic|sysprof}} as a ''system'' package (it won't work properly if installed against users). Then enable the associated service with
you will need to add <code>pkgs.gnome2.GConf</code> to the list of dbus packages in your NixOS configuration like so:


<syntaxHighlight lang="nix">
{{File|3={
   services.sysprof.enable = true;
   services.dbus.packages = with pkgs; [ gnome2.GConf ];
</syntaxHighlight>
}|name=/etc/nixos/configuration.nix|lang=nix}}


=== Automatic screen rotation ===
After rebuilding your configuration, restart your desktop session to have GConf take effect.
 
<syntaxHighlight lang="nix">
  hardware.sensor.iio.enable = true;
</syntaxHighlight>
 
== Troubleshoots ==
 
=== Change user's profile picture ===
Currently there is no way to change the user's profile picture using Gnome Control Center [https://github.com/NixOS/nixpkgs/issues/10025 (see this issue)] and currently there is no plan to support it officially in NixOS. However, you can modify it by copying the profile picture that you want to the path '''/home/$USER/.face''' as a workaround, i.e.
 
<syntaxHighlight lang="console">
$ mv /path/to/image.jpg ~/.face
</syntaxHighlight>
 
==== Change Profile Photo for Login and Lockscreen - Declarative ====
This is admittedly a hack way of doing it, however does work.
 
Considerations:
 
* image must be a PNG
* permissions matter
* this is absolutely a workaround
* assumes you are already using a .face file
* you will need to update the paths and username as applicable to your system (CAPITALIZED in the code)
* you cannot change the photo using Gnome Control Center


=== Automatic login ===


You can place this in your configuration.nix:<syntaxhighlight lang="nix">
As a potential workaround<ref>https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229</ref> for automatic login, include this in your NixOS configuration:
system.activationScripts.script.text = ''
    mkdir -p /var/lib/AccountsService/{icons,users}
    cp /home/YOUR-USER-NAME/PATH-TO/.face /var/lib/AccountsService/icons/YOUR-USER-NAME
    echo -e "[User]\nIcon=/var/lib/AccountsService/icons/YOUR-USER-NAME\n" > /var/lib/AccountsService/users/YOUR-USER-NAME


    chown root:root /var/lib/AccountsService/users/YOUR-USER-NAME
{{File|3={
    chmod 0600 /var/lib/AccountsService/users/YOUR-USER-NAME
  services.xserver.displayManager.autoLogin.enable = true;
 
  services.xserver.displayManager.autoLogin.user = "account";
    chown root:root /var/lib/AccountsService/icons/YOUR-USER-NAME
 
    chmod 0444 /var/lib/AccountsService/icons/YOUR-USER-NAME
'';
</syntaxhighlight>
 
=== Automatic login ===
 
If you have enabled [https://help.gnome.org/admin/system-admin-guide/stable/login-automatic.html.en auto login] (with <!-- [[GDM]] -->[[{{PAGENAME}}]]) with something like
: <syntaxHighlight lang="console">
$ grep autoLogin /etc/nixos/configuration.nix
</syntaxHighlight>
<syntaxHighlight lang="nix">
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "account";
</syntaxHighlight>
than add the following (as a workaround for a current (2023)<ref>https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229</ref> problem)
: <syntaxHighlight lang="console"># nano /etc/nixos/configuration.nix</syntaxHighlight>
<syntaxHighlight lang="nix">
{
   systemd.services."getty@tty1".enable = false;
   systemd.services."getty@tty1".enable = false;
   systemd.services."autovt@tty1".enable = false;
   systemd.services."autovt@tty1".enable = false;
}
}|name=/etc/nixos/configuration.nix|lang=nix}}
</syntaxHighlight>
 
== See also ==
* [[GNOME/Calendar]]


=== GDM does not show user ===
The GDM (GNOME Display Manager) will not display a user if their default shell is not listed in <code>/etc/shells</code>. If your shell, such as zsh, is not included in <code>/etc/shells</code>, you need to add it to the configuration.{{File|3={
  environment.shells = with pkgs; [ zsh ];
}|name=/etc/nixos/configuration.nix|lang=nix}}
:
== References ==
[[Category:Desktop environment]]
[[Category:Desktop environment]]
[[Category:Applications]]
[[Category:Applications]]
[[Category:NixOS Manual]]
[[Category:NixOS Manual]]
[[Category:GNOME]]
[[Category:GNOME]]

Latest revision as of 02:32, 31 August 2025

GNOME (/(ɡ)noʊm/) is a desktop environment that seeks to be "an independent computing platform for everyone."[1]

This article is an extension of the documentation in the NixOS manual.

Installation

GNOME desktop

To use the GNOME desktop environment on NixOS, the following configuration options must be set:

❄︎ /etc/nixos/configuration.nix
{ config, pkgs, ... }:

{

  # Pre 25.11
  services.xserver.enable = true;
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  # As of 25.11
  services.displayManager.gdm.enable = true;
  services.desktopManager.gnome.enable = true;

  # To disable installing GNOME's suite of applications
  # and only be left with GNOME shell.
  services.gnome.core-apps.enable = false;
  services.gnome.core-developer-tools.enable = false;
  services.gnome.games.enable = false;
  environment.gnome.excludePackages = with pkgs; [ gnome-tour gnome-user-docs ];

}

Despite the options in NixOS versions before 25.11 being under the xserver module, GNOME uses Wayland by default. NixOS 25.11 and later removes support for the Xorg session entirely (though Xwayland is still included and supported for compatibility).

GNOME extensions

GNOME offers support for changing/overhauling the user interface (GNOME Shell) through the use of Extensions. Extensions are bundles of third-party GJS modules that are loaded while GNOME is running to augment the user experience. A repository of GNOME extensions can be found on GNOME's official webpage and can be installed imperatively if needed by unpacking the extension in ~/.local/share/gnome-shell/extensions directory. Extensions can only be activated if it supports the GNOME release that it's installed alongside with.

In addition, NixOS automatically packages all officially available GNOME extensions under the pkgs.gnomeExtensions attribute. Extensions which require additional dependencies are then manually packaged if needed. Installed extensions can be enabled graphically through the built-in "Extensions" application or through the gnome-extensions command line interface.

❄︎ /etc/nixos/configuration.nix
{
  environment.systemPackages = with pkgs; [
    gnomeExtensions.blur-my-shell
    gnomeExtensions.just-perfection
    gnomeExtensions.arc-menu
  ];
}

Configuration

dconf

Dconf is a low-level configuration system for storing and loading configurations. The dconf database is stored in a single binary file in ~/.config/dconf/user and contains all known configuration values for all applications and programs that use dconf (GNOME applications and shell, gtk, etc).

For example, the setting which controls the accent color of GNOME shell is located in the schema labeled /org/gnome/desktop/interface/ which contains the key accent-color which accepts a GVariant value of type enum (one of 'blue', 'teal', 'green', etc)

NixOS and Home Manager both provide an interface for declarative configuration of dconf settings exposed in programs.dconf and dconf modules respectively.

Going back to the previous example, to set the accent color of GNOME in a declarative manner in NixOS as well as mapping the keyboard's "caps lock" key to "ctrl" you would write:

❄︎ /etc/nixos/configuration.nix
{
  programs.dconf.profiles.user.databases = [
    {
      lockAll = true; # prevents overriding
      settings = {
        "org/gnome/desktop/interface" = {
          accent-color = "blue";
        };
        "org/gnome/desktop/input-sources" = {
          xkb-options = [ "ctrl:nocaps" ];
        };
      };
    }
  ];
}

And the equivalent snippet in Home Manager:

❄︎ ~/.config/home-manager/home.nix
{
  dconf.enable = true;
  dconf.settings = {
    "org/gnome/desktop/interface" = {
      accent-color = "blue";
    };
    "org/gnome/desktop/input-sources" = {
      xkb-options = [ "ctrl:nocaps" ];
    };
  };
}

Thus the settings attribute accepts an attribute set whose keys are schemas with each schema's value being a nested attribute set of the schema's keys with their appropriate GVariant value.

Note: Schemas in Nix are written without leading and trailing slashes. In addition, since dconf have more data types than the Nix language (for example, tuples), in some cases you'll need to convert Nix value to a GVariant value. You can achieve that by using the functions defined under lib.gvariant, they're documented here.

If you wish to revert all dconf settings back to their default state (reset GNOME essentially) then use the following command which resets all schemas directories available on your system, note that this will affect all programs that use dconf, including GNOME apps and extensions.

$ dconf reset -f /

Extensions

Extensions are not activated by default when installed with Nix but can be configured to do so using the respective dconf modules. The schema is /org/gnome/shell/ with the key enabled-extensions which accepts a list of strings that represent extension UUIDs. If the extension was installed with Nix, then the UUID can be accessed by the extensionUuid attribute of the extension itself. Each extension's configuration can then be found under their corresponding schema in /org/gnome/shell/extensions/ and be configured as needed.

For example, in Home Manager, you could write:

❄︎ ~/.config/home-manager/home.nix
{
  dconf = {
    enable = true;
    settings = {
      "org/gnome/shell" = {
        # disable-user-extensions = true; # Optionally disable user extensions entirely
        enabled-extensions = [
          # Put UUIDs of extensions that you want to enable here.
          # If the extension you want to enable is packaged in nixpkgs,
          # you can easily get its UUID by accessing its extensionUuid
          # field (look at the following example).
          pkgs.gnomeExtensions.gsconnect.extensionUuid

          # Alternatively, you can manually pass UUID as a string.
          "blur-my-shell@aunetx"
          # ...
        ];
      };

      # Configure individual extensions
      "org/gnome/shell/extensions/blur-my-shell" = {
        brightness = 0.75;
        noise-amount = 0;
      };
    };
  };
}

Tips and tricks

GNOME power user apps

Both GNOME Tweaks (accessible as gnome-tweaks) and Refine (accessible as refine) allow you to change certain GNOME settings that are hidden by default (such as interface font, window decoration buttons like maximize/minimize, icon themes and GTK themes, etc).

The GNOME shell extension Just Perfection also allows for customizing nearly all parts of the GNOME shell interface.

GNOME Qt integration

Using the following example configuration, Qt applications will have a look similar to the adwaita style used by GNOME using a dark theme.

❄︎ /etc/nixos/configuration.nix
{
  qt = {
    enable = true;
    platformTheme = "gnome";
    style = "adwaita-dark";
  };
}

For other themes, you may need the packages libsForQt5.qt5ct and libsForQt5.qtstyleplugin-kvantum and a symlink from ~/.config/Kvantum/ to your theme package. Here is an example using Arc-Dark and Home Manager. In the Home Manager configuration:

❄︎ ~/.config/home-manager/home.nix
{
  qt = {
    enable = true;
    platformTheme = "qtct";
    style = "kvantum";
  };

  xdg.configFile = {
    "Kvantum/ArcDark".source = "${pkgs.arc-kde-theme}/share/Kvantum/ArcDark";
    "Kvantum/kvantum.kvconfig".text = "[General]\ntheme=ArcDark";
  };
}

For more details, see this forum post.

Note: Qt integration with the adwaita style isn't perfect and your mileage may vary.

Experimental settings

GNOME has a number of experimental settings for features not fully completed and thus hidden from the user. As of GNOME 48, these are the experimental features you may want to use:

❄︎ /etc/nixos/configuration.nix
{
  programs.dconf.profiles.user.databases = [
    {
      settings = {
        "org/gnome/mutter" = {
          experimental-features = [
            "scale-monitor-framebuffer" # Enables fractional scaling (125% 150% 175%)
            "variable-refresh-rate" # Enables Variable Refresh Rate (VRR) on compatible displays
            "xwayland-native-scaling" # Scales Xwayland applications to look crisp on HiDPI screens
          ];
        };
      };
    }
  ];
}

Discover dconf settings

If you wish to discover the corresponding dconf entry for a given setting in a program, you can run `dconf watch /` inside of a terminal and change the setting graphically. For example, when changing toggling the Quick-Settings option "Dark Style" from "on" to "off" and back to "on," this will be the output:

$ dconf watch /
/org/gnome/desktop/interface/color-scheme
  'default'

/org/gnome/desktop/interface/color-scheme
  'prefer-dark'

Otherwise you can use the gsettings programs to inspect the schemas installed on your system. For example, to inspect all the keys contained within /org/gnome/desktop/background you could run:

$ gsettings list-keys org.gnome.desktop.background
color-shading-type
picture-opacity
picture-options
picture-uri
picture-uri-dark
primary-color
secondary-color
show-desktop-icons

Then to see the range of possible values for one of the keys such as picture-options you could then run:

$ gsettings range org.gnome.desktop.background picture-options
enum
'none'
'wallpaper'
'centered'
'scaled'
'stretched'
'zoom'
'spanned'

Which tells you that the key picture-options located in schema /org/gnome/desktop/background/ accepts a value of type enumeration (a single string value from a set of accepted values).

Enable system tray icons

GNOME does not currently support system tray icons. However, Ubuntu has created an extension that implements this in the top bar. You can install this extension with the following in NixOS:

❄︎ /etc/nixos/configuration.nix
{
  environment.systemPackages = [ pkgs.gnomeExtensions.appindicator  ];
  services.udev.packages = [ pkgs.gnome-settings-daemon ];
}

Profiling (with sysprof)

Install sysprof as a system package (it won't work properly if installed against users). Then enable the associated service with

  services.sysprof.enable = true;

Automatic screen rotation

  hardware.sensor.iio.enable = true;

Dark mode

Change default color theme for all GTK4 applications to dark using Home Manager.

❄︎ ~/.config/home-manager/home.nix
{
  dconf = {
    enable = true;
    settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
  };
}

Excluding GNOME Applications

To exclude certain applications that are installed by default with GNOME, set the environment.gnome.excludePackages module option (Optional Packages: gnome.nix):

❄︎ /etc/nixos/configuration.nix
  environment.gnome.excludePackages = with pkgs; [
    totem
  ];

Troubleshooting

Missing cursor/cursor is a white box

This occurs when installing GNOME from an existing NixOS installation that used a different desktop environment that modified dconf (most likely switching from KDE to GNOME). To easily fix this: reset all dconf settings.

$ dconf reset -f /

Running GConf-based applications

There exist very old applications which use the deprecated GConf service to store configuration. If you are running such an application and are getting an error like:

GLib.GException: Failed to contact configuration server; the most common cause is a missing or misconfigured D-Bus session bus daemon. See http://projects.gnome.org/gconf/ for information

you will need to add pkgs.gnome2.GConf to the list of dbus packages in your NixOS configuration like so:

❄︎ /etc/nixos/configuration.nix
{
  services.dbus.packages = with pkgs; [ gnome2.GConf ];
}

After rebuilding your configuration, restart your desktop session to have GConf take effect.

Automatic login

As a potential workaround[2] for automatic login, include this in your NixOS configuration:

❄︎ /etc/nixos/configuration.nix
{
  services.xserver.displayManager.autoLogin.enable = true;
  services.xserver.displayManager.autoLogin.user = "account";
  
  systemd.services."getty@tty1".enable = false;
  systemd.services."autovt@tty1".enable = false;
}

GDM does not show user

The GDM (GNOME Display Manager) will not display a user if their default shell is not listed in /etc/shells. If your shell, such as zsh, is not included in /etc/shells, you need to add it to the configuration.

❄︎ /etc/nixos/configuration.nix
{
  environment.shells = with pkgs; [ zsh ];
}

References