nixpkgs/nixos/modules/services/x11/desktop-managers/gnome.md
Janne Heß fcc95ff817 treewide: Fix all Nix ASTs in all markdown files
This allows for correct highlighting and maybe future automatic
formatting. The AST was verified to work with nixfmt only.
2024-03-28 09:28:12 +01:00

7.0 KiB
Raw Blame History

GNOME Desktop

GNOME provides a simple, yet full-featured desktop environment with a focus on productivity. Its Mutter compositor supports both Wayland and X server, and the GNOME Shell user interface is fully customizable by extensions.

Enabling GNOME

All of the core apps, optional apps, games, and core developer tools from GNOME are available.

To enable the GNOME desktop use:

{
  services.xserver.desktopManager.gnome.enable = true;
  services.xserver.displayManager.gdm.enable = true;
}

::: {.note} While it is not strictly necessary to use GDM as the display manager with GNOME, it is recommended, as some features such as screen lock might not work without it. :::

The default applications used in NixOS are very minimal, inspired by the defaults used in gnome-build-meta.

GNOME without the apps

If youd like to only use the GNOME desktop and not the apps, you can disable them with:

{
  services.gnome.core-utilities.enable = false;
}

and none of them will be installed.

If youd only like to omit a subset of the core utilities, you can use . Note that this mechanism can only exclude core utilities, games and core developer tools.

Disabling GNOME services

It is also possible to disable many of the core services. For example, if you do not need indexing files, you can disable Tracker with:

{
  services.gnome.tracker-miners.enable = false;
  services.gnome.tracker.enable = false;
}

Note, however, that doing so is not supported and might break some applications. Notably, GNOME Music cannot work without Tracker.

GNOME games

You can install all of the GNOME games with:

{
  services.gnome.games.enable = true;
}

GNOME core developer tools

You can install GNOME core developer tools with:

{
  services.gnome.core-developer-tools.enable = true;
}

Enabling GNOME Flashback

GNOME Flashback provides a desktop environment based on the classic GNOME 2 architecture. You can enable the default GNOME Flashback session, which uses the Metacity window manager, with:

{
  services.xserver.desktopManager.gnome.flashback.enableMetacity = true;
}

It is also possible to create custom sessions that replace Metacity with a different window manager using .

The following example uses xmonad window manager:

{
  services.xserver.desktopManager.gnome.flashback.customSessions = [
    {
      wmName = "xmonad";
      wmLabel = "XMonad";
      wmCommand = "${pkgs.haskellPackages.xmonad}/bin/xmonad";
      enableGnomePanel = false;
    }
  ];
}

Icons and GTK Themes

Icon themes and GTK themes dont require any special option to install in NixOS.

You can add them to and switch to them with GNOME Tweaks. If youd like to do this manually in dconf, change the values of the following keys:

/org/gnome/desktop/interface/gtk-theme
/org/gnome/desktop/interface/icon-theme

in dconf-editor

Shell Extensions

Most Shell extensions are packaged under the gnomeExtensions attribute. Some packages that include Shell extensions, like gnome.gpaste, dont have their extension decoupled under this attribute.

You can install them like any other package:

{
  environment.systemPackages = [
    gnomeExtensions.dash-to-dock
    gnomeExtensions.gsconnect
    gnomeExtensions.mpris-indicator-button
  ];
}

Unfortunately, we lack a way for these to be managed in a completely declarative way. So you have to enable them manually with an Extensions application. It is possible to use a GSettings override for this on org.gnome.shell.enabled-extensions, but that will only influence the default value.

GSettings Overrides

Majority of software building on the GNOME platform use GLibs GSettings system to manage runtime configuration. For our purposes, the system consists of XML schemas describing the individual configuration options, stored in the package, and a settings backend, where the values of the settings are stored. On NixOS, like on most Linux distributions, dconf database is used as the backend.

GSettings vendor overrides can be used to adjust the default values for settings of the GNOME desktop and apps by replacing the default values specified in the XML schemas. Using overrides will allow you to pre-seed user settings before you even start the session.

::: {.warning} Overrides really only change the default values for GSettings keys so if you or an application changes the setting value, the value set by the override will be ignored. Until NixOSs dconf module implements changing values, you will either need to keep that in mind and clear the setting from the backend using dconf reset command when that happens, or use the module from home-manager. :::

You can override the default GSettings values using the option.

Take note that whatever packages you want to override GSettings for, you need to add them to .

You can use dconf-editor tool to explore which GSettings you can set.

Example

{
  services.xserver.desktopManager.gnome = {
    extraGSettingsOverrides = ''
      # Change default background
      [org.gnome.desktop.background]
      picture-uri='file://${pkgs.nixos-artwork.wallpapers.mosaic-blue.gnomeFilePath}'

      # Favorite apps in gnome-shell
      [org.gnome.shell]
      favorite-apps=['org.gnome.Console.desktop', 'org.gnome.Nautilus.desktop']
    '';

    extraGSettingsOverridePackages = [
      pkgs.gsettings-desktop-schemas # for org.gnome.desktop
      pkgs.gnome.gnome-shell # for org.gnome.shell
    ];
  };
}

Frequently Asked Questions

Can I use LightDM with GNOME?

Yes you can, and any other display-manager in NixOS.

However, it doesnt work correctly for the Wayland session of GNOME Shell yet, and wont be able to lock your screen.

See this issue.