GNOME: Difference between revisions

Normalcea (talk | contribs)
Remove section on adwaita icons as GNOME upstream have clarified that it is not a freedesktop compliant icon theme. https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/issues/288
Normalcea (talk | contribs)
Dynamic triple buffering: Remove section as triple buffering has been merged as part of the GNOME 48 release in NixOS 25.05.
Line 249: Line 249:


After applying the update restart your 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 ===
{{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!}}
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>
{
  nixpkgs.overlays = [
    # 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>}}
For GNOME 47, use the following configuration instead:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  nixpkgs.overlays = [
    # GNOME 47: triple-buffering-v4-47
    (final: prev: {
      mutter = prev.mutter.overrideAttrs (oldAttrs: {
        # GNOME dynamic triple buffering (huge performance improvement)
        # See https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441
        # Also https://gitlab.gnome.org/vanvugt/mutter/-/tree/triple-buffering-v4-47
        src = final.fetchFromGitLab {
          domain = "gitlab.gnome.org";
          owner = "vanvugt";
          repo = "mutter";
          rev = "triple-buffering-v4-47";
          hash = "sha256-Jlhzt2Cc44epkBcz3PA6I5aTnVEqMsHBOE8aEmvANWw=";
        };
        # GNOME 47 requires the gvdb subproject which is not included in the triple-buffering branch
        # This copies the necessary gvdb files from the official GNOME repository
        preConfigure = let
          gvdb = final.fetchFromGitLab {
            domain = "gitlab.gnome.org";
            owner = "GNOME";
            repo = "gvdb";
            rev = "2b42fc75f09dbe1cd1057580b5782b08f2dcb400";
            hash = "sha256-CIdEwRbtxWCwgTb5HYHrixXi+G+qeE1APRaUeka3NWk=";
          };
        in ''
          cp -a "${gvdb}" ./subprojects/gvdb
        '';
      });
    })
  ];
}
</nowiki>}}
==== Flakes approach ====
If you're using flakes, you can add the repositories as inputs.
It will save you the burden of updating the dependencies manually, but at a cost of laziness: they will always be fetched regardless of whether they're actually needed to build the current artifact/configuration. This may not be always desirable.
{{file|flake.nix (inputs section)|nix|<nowiki>
{
  # In inputs:
  mutter-triple-buffering-src = {
    url = "gitlab:vanvugt/mutter?ref=triple-buffering-v4-47&host=gitlab.gnome.org";
    flake = false;
  };
  gvdb-src = {
    url = "gitlab:GNOME/gvdb?ref=main&host=gitlab.gnome.org";
    flake = false;
  };
}
</nowiki>}}
Then, in your overlay section:
{{file|flake.nix (overlay section)|nix|<nowiki>
{
  # In your overlay:
  mutter = super.mutter.overrideAttrs (old: {
    src = inputs.mutter-triple-buffering-src;
    preConfigure = ''
      cp -a "${inputs.gvdb-src}" ./subprojects/gvdb
    '';
  });
}
</nowiki>}}
{{Note|For GNOME 47, the gvdb dependency must be manually added to the subprojects directory during build. The preConfigure hook handles this by fetching the required repository and placing it in the correct location.}}
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:
{{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>}}
You might need to disable aliases to make it work:
<syntaxHighlight lang="nix">
  nixpkgs.config.allowAliases = false;
</syntaxHighlight>'''NOTE''' - the "allowAliases" set to false has been known to break stylix (if you use it).


=== Profiling (with sysprof) ===
=== Profiling (with sysprof) ===