GNOME: Difference between revisions

Added examples of managing extensions; updated dynamic triple buffering overlay, added warning; added curly braces (as NixOS manual do) to configuration examples to indicate its type (attribute set).
m removed blank line
(5 intermediate revisions by the same user not shown)
Line 24: Line 24:
{
{
   environment.gnome.excludePackages = (with pkgs; [
   environment.gnome.excludePackages = (with pkgs; [
     # for packages that are pkgs.***
     # for packages that are pkgs.*
     gnome-tour
     gnome-tour
     gnome-connections
     gnome-connections
Line 38: Line 38:
== Configuration ==
== Configuration ==


=== Managing Extensions ===
=== Managing extensions ===


GNOME extensions are managed and configured by the program "Extensions" that comes with GNOME.
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.
 
Extensions can be installed with Nix, however they aren't enabled by default. To enable them the "Extensions" program can be used.


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
Line 54: Line 52:
</nowiki>}}
</nowiki>}}


Extension can be enabled and configured in your system configuration. Look at the following example.
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.
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  programs.dconf = {
    enable = true;
    profiles.user.databases = [
      {
        settings = {
          "org/gnome/shell" = {
            disable-user-extensions = false; # enables user extensions (disabled by default)
            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.blur-my-shell.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;
          };
        };
      }
    ];
  };
}
</nowiki>}}
 
Same result can be achieved for specific user only by using [[Home Manager]] module.


{{file|~/.config/home-manager/home.nix|nix|<nowiki>
{{file|~/.config/home-manager/home.nix|nix|<nowiki>
Line 97: Line 60:
     settings = {
     settings = {
       "org/gnome/shell" = {
       "org/gnome/shell" = {
         disable-user-extensions = false;
         disable-user-extensions = false; # enables user extensions
         enabled-extensions = [
         enabled-extensions = [
           pkgs.gnomeExtensions.blur-my-shell.extensionUuid   
          # 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"
           "blur-my-shell@aunetx"
           # ...
           # ...
Line 105: Line 74:
       };
       };


      # Configure individual extensions
       "org/gnome/shell/extensions/blur-my-shell" = {
       "org/gnome/shell/extensions/blur-my-shell" = {
         brightness = 0.75;
         brightness = 0.75;
Line 114: Line 84:
</nowiki>}}
</nowiki>}}


To learn about settings that can be configured with dconf either look into "dconf-editor" 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.
=== dconf settings ===
 
Most of the GNOME settings are stored in [https://en.wikipedia.org/wiki/Dconf dconf] database. Settings are stored as keys placed in folders.
 
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.
 
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).
 
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|~/.config/home-manager/home.nix|nix|<nowiki>
{
  dconf.settings = {
    enable = true;
 
    # You need quotes to escape '/'
    "org/gnome/desktop/interface" = {
      clock-show-weekday = true;
    };
  };
}
</nowiki>}}
 
Same can be achieved by using system configuration.
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  programs.dconf = {
    enable = true;
    profiles.user.databases = [
      {
        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].}}


=== Dark mode ===
=== Dark mode ===
Line 254: Line 267:


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
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">
: <syntaxHighlight lang="console">
grep autoLogin /etc/nixos/configuration.nix
$ grep autoLogin /etc/nixos/configuration.nix
</syntaxHighlight>
</syntaxHighlight>
<syntaxHighlight lang="nix">
<syntaxHighlight lang="nix">
Line 262: Line 275:
</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)
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="console"># nano /etc/nixos/configuration.nix</syntaxHighlight>
<syntaxHighlight lang="nix">
<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;
}
</syntaxHighlight>
</syntaxHighlight>


== Also see ==
== See also ==
 
* [[GNOME/Calendar]]
[[GNOME/Calendar]]


[[Category:Desktop environment]]
[[Category:Desktop environment]]
[[Category:Applications]]
[[Category:Applications]]
[[Category:NixOS Manual]]
[[Category:NixOS Manual]]