GNOME: Difference between revisions

From NixOS Wiki
imported>Pancho
m (→‎Systray Icons: Fix typo)
(added link to nixos manual)
 
(32 intermediate revisions by 24 users not shown)
Line 1: Line 1:
GNOME (/(ɡ)noʊm/) is a desktop environment that aims to be simple and easy to use. It is designed by The GNOME Project and is composed entirely of free and open-source software. GNOME is a part of the GNU Project.


[[{{PAGENAME}}]] (/(ɡ)noʊm/) is a [[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.


== Installing GNOME ==
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 ==


To use GNOME, add this to your configuration.nix:
To use GNOME, add this to your configuration.nix:


<syntaxHighlight>
<syntaxHighlight lang=nix>
services.xserver.enable = true;
services.xserver.enable = true;
services.xserver.displayManager.gdm.enable = true;
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome3.enable = true;
services.xserver.desktopManager.gnome.enable = true;
</syntaxHighlight>
 
=== Excluding GNOME Applications ===
 
To exclude certain applications that are installed by default with GNOME edit {{ic|configuration.nix}} as follows:
 
<syntaxhighlight lang="nixos">
environment.gnome.excludePackages = (with pkgs; [
  # for packages that are pkgs.***
  gnome-tour
  gnome-connections
]) ++ (with pkgs.gnome; [
  # for packages that are pkgs.gnome.***
  epiphany # web browser
  geary # email reader
  evince # document viewer
]);
</syntaxhighlight>
 
== Configuration ==
 
=== Managing Extensions ===
 
GNOME extensions are managed and configured by the program "Extensions" that comes with GNOME.
 
Extensions can be installed with Nix, however they aren't enabled by default. To enable them the "Extensions" program can be used.
<syntaxhighlight lang="nixos">
environment.systemPackages = (with pkgs.gnomeExtensions; [
  blur-my-shell
  pop-shell
  # ***
]);
</syntaxhighlight>
 
To declaratively enable and configure, use of modules like home-manager you are required to configure dconf settings.
 
<syntaxhighlight lang="nixos">
dconf = {
        enable = true;
        settings = {
                "org/gnome/shell" = {
                        disabled-user-extensions = false; # enables user extensions (disabled by default)
                        enabled-extensions = [
                                "blur-my-shell@aunetx"
                                # ****
                        ];
                };
 
                # Configure individual extensions
                "org/gnome/shell/extensions/blur-my-shell" = {
                        brightness = 0.75;
                        noise-amount = 0;
                };
        };
};
</syntaxhighlight>
 
To learn about settings that can be configured with dconf either look into "dconf editor" program or type <syntaxhighlight lang="shell">dconf watch /</syntaxhighlight> in the terminal and change settings from the GUI and see which options are responsible for that component/element.
 
 
=== Dark mode ===
 
Change default color theme for all GTK4 applications to dark using [[Home Manager]]. Change <code>myuser</code> to the user you want to apply the configuration to.
 
<syntaxhighlight lang="nix">
home-manager.users.myuser = {
        dconf = {
                enable = true;
                settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
        };
};
</syntaxhighlight>
 
== Tips and tricks ==
 
=== 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.
 
For instance, if you see the following error:
 
<syntaxhighlight lang="text">
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:
 
<syntaxHighlight lang=nix>
programs.dconf.enable = true;
</syntaxHighlight>
</syntaxHighlight>


== Running ancient applications ==
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.


Long ago, in the GNOME 2 era, applications used 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:
<syntaxHighlight lang=nix>
environment.systemPackages = [ gnome.adwaita-icon-theme ];
</syntaxHighlight>


<syntaxHighlight>
=== Systray Icons ===
 
To get systray icons, install the related gnome shell extension
 
<syntaxHighlight lang=nix>
environment.systemPackages = with pkgs; [ gnomeExtensions.appindicator ];
</syntaxHighlight>
 
And ensure gnome-settings-daemon udev rules are enabled :
 
<syntaxHighlight lang=nix>
services.udev.packages = with pkgs; [ gnome.gnome-settings-daemon ];
</syntaxHighlight>
 
=== To run old applications ===
 
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:
 
<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
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>
</syntaxHighlight>
Line 26: Line 138:
</syntaxHighlight>
</syntaxHighlight>


After applying the update one also has restart their desktop session to refresh the user-specific dbus session.
After applying the update restart your desktop session to refresh the user-specific dbus session.
 
=== Dynamic triple buffering ===
 
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.


== Running GNOME programs outside of GNOME ==
For NixOS 23.11 (gnome 45), add the following:


While we are packaging GNOME platform-based applications to be largely [https://nixos.org/nixpkgs/manual/#sec-language-gnome self-contained], 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 lang="nix">
nixpkgs.overlays = [
        (final: prev: {
                gnome = prev.gnome.overrideScope (gnomeFinal: gnomePrev: {
                        mutter = gnomePrev.mutter.overrideAttrs ( old: {
                                src = pkgs.fetchgit {
                                        url = "https://gitlab.gnome.org/vanvugt/mutter.git";
                                        rev = "0b896518b2028d9c4d6ea44806d093fd33793689";
                                        sha256 = "sha256-mzNy5GPlB2qkI2KEAErJQzO//uo8yO0kPQUwvGDwR4w=";
                                };
                        });
                });
        })
];
</syntaxhighlight>


For instance, if you see the following error:
For NixOS 24.05 (gnome 46), add the following:
 
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
        (final: prev: {
                gnome = prev.gnome.overrideScope (gnomeFinal: gnomePrev: {
                        mutter = gnomePrev.mutter.overrideAttrs ( old: {
                                src = pkgs.fetchgit {
                                        url = "https://gitlab.gnome.org/vanvugt/mutter.git";
                                        rev = "663f19bc02c1b4e3d1a67b4ad72d644f9b9d6970";
                                        sha256 = "sha256-I1s4yz5JEWJY65g+dgprchwZuPGP9djgYXrMMxDQGrs=";
                                };
                        });
                });
        })
];
 
</syntaxhighlight>
 
You might need to disable aliases to make it work:


<syntaxHighlight>
<syntaxHighlight lang=nix>
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
nixpkgs.config.allowAliases = false;
</syntaxHighlight>
</syntaxHighlight>


you should enable dconf module:
=== Profiling (with sysprof) ===
 
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>
<syntaxHighlight lang=nix>
programs.dconf.enable = true;
services.sysprof.enable = true;
</syntaxHighlight>
</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.
=== Automatic screen rotation ===


<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
environment.systemPackages = [ gnome3.adwaita-icon-theme ];
hardware.sensor.iio.enable = true;
</syntaxHighlight>
</syntaxHighlight>


== Systray Icons ==
== Troubleshoots ==


To get systray icons, install the related gnome shell extension
=== 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=nix>
<syntaxHighlight lang=console>
environment.systemPackages = [ gnome-shell-extension-appindicator-32 ];
$ mv /path/to/image.jpg ~/.face
</syntaxHighlight>
</syntaxHighlight>


And ensure gnome-settings-daemon udev rules are enabled :
=== 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=bash>
grep autoLogin /etc/nixos/configuration.nix
</syntaxHighlight>
<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
services.udev.packages = with pkgs; [ gnome3.gnome-settings-daemon ];
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "account";
</syntaxHighlight>
</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."autovt@tty1".enable = false;
</syntaxHighlight>
.


== Also see ==
== Also see ==


[[GNOME/Calendar]]
[[GNOME/Calendar]]
[[Category:Desktop environment]]
[[Category:Applications]]
[[Category:NixOS Manual]]

Latest revision as of 19:31, 16 May 2024

GNOME (/(ɡ)noʊm/) is a 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.

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

GNOME is available as a module and can be enabled with services.xserver.desktopManager.

Installation

To use GNOME, add this to your configuration.nix:

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

Excluding GNOME Applications

To exclude certain applications that are installed by default with GNOME edit configuration.nix as follows:

environment.gnome.excludePackages = (with pkgs; [
  # for packages that are pkgs.***
  gnome-tour
  gnome-connections
]) ++ (with pkgs.gnome; [
  # for packages that are pkgs.gnome.***
  epiphany # web browser
  geary # email reader
  evince # document viewer
]);

Configuration

Managing Extensions

GNOME extensions are managed and configured by the program "Extensions" that comes with GNOME.

Extensions can be installed with Nix, however they aren't enabled by default. To enable them the "Extensions" program can be used.

environment.systemPackages = (with pkgs.gnomeExtensions; [
  blur-my-shell
  pop-shell
  # ***
]);

To declaratively enable and configure, use of modules like home-manager you are required to configure dconf settings.

dconf = {
        enable = true;
        settings = {
                "org/gnome/shell" = {
                        disabled-user-extensions = false; # enables user extensions (disabled by default)
                        enabled-extensions = [
                                "blur-my-shell@aunetx"
                                # ****
                        ];
                };

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

To learn about settings that can be configured with dconf either look into "dconf editor" program or type

dconf watch /

in the terminal and change settings from the GUI and see which options are responsible for that component/element.


Dark mode

Change default color theme for all GTK4 applications to dark using Home Manager. Change myuser to the user you want to apply the configuration to.

home-manager.users.myuser = {
        dconf = {
                enable = true;
                settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
        };
};

Tips and tricks

To run GNOME programs outside of GNOME

GNOME platform-based applications are largely self-contained, but they still depend, for one reason or another, on some global configuration. The 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.

For instance, if you see the following error:

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

you should enable dconf module:

programs.dconf.enable = true;

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.

environment.systemPackages = [ gnome.adwaita-icon-theme ];

Systray Icons

To get systray icons, install the related gnome shell extension

environment.systemPackages = with pkgs; [ gnomeExtensions.appindicator ];

And ensure gnome-settings-daemon udev rules are enabled :

services.udev.packages = with pkgs; [ gnome.gnome-settings-daemon ];

To run old applications

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:

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 need to add gnome2.GConf to the list of dbus packages in your configuration.nix:

services.dbus.packages = with pkgs; [ gnome2.GConf ];

After applying the update restart your desktop session to refresh the user-specific dbus session.

Dynamic triple buffering

Big 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 philosophy of nixpkgs, but users are free to add this overlay to get it too.

For NixOS 23.11 (gnome 45), add the following:

nixpkgs.overlays = [
        (final: prev: {
                gnome = prev.gnome.overrideScope (gnomeFinal: gnomePrev: {
                        mutter = gnomePrev.mutter.overrideAttrs ( old: {
                                src = pkgs.fetchgit {
                                        url = "https://gitlab.gnome.org/vanvugt/mutter.git";
                                        rev = "0b896518b2028d9c4d6ea44806d093fd33793689";
                                        sha256 = "sha256-mzNy5GPlB2qkI2KEAErJQzO//uo8yO0kPQUwvGDwR4w=";
                                };
                        });
                });
        })
];

For NixOS 24.05 (gnome 46), add the following:

nixpkgs.overlays = [
        (final: prev: {
                gnome = prev.gnome.overrideScope (gnomeFinal: gnomePrev: {
                        mutter = gnomePrev.mutter.overrideAttrs ( old: {
                                src = pkgs.fetchgit {
                                        url = "https://gitlab.gnome.org/vanvugt/mutter.git";
                                        rev = "663f19bc02c1b4e3d1a67b4ad72d644f9b9d6970";
                                        sha256 = "sha256-I1s4yz5JEWJY65g+dgprchwZuPGP9djgYXrMMxDQGrs=";
                                };
                        });
                });
        })
];

You might need to disable aliases to make it work:

nixpkgs.config.allowAliases = false;

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;

Troubleshoots

Change user's profile picture

Currently there is no way to change the user's profile picture using Gnome Control Center (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.

$ mv /path/to/image.jpg ~/.face

automatic login

If you have enabled auto login (with GNOME) with something like

grep autoLogin /etc/nixos/configuration.nix
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "account";

than add the following (as a workaround for a current (2023)[1] problem)

# nano /etc/nixos/configuration.nix
systemd.services."getty@tty1".enable = false;
systemd.services."autovt@tty1".enable = false;

.

Also see

GNOME/Calendar