GDM Background Image and Theme

DiCaius’s patch failed to apply, and I found why: _screen-shield.scss has changed from [1] to [2].

Good news, though! I have a new solution.

I found a feature request open asking for GNOME to support this very thing: Feature request: Make GDM background color and image configurable with gsettings. (#3877) · Issues · GNOME / gnome-shell · GitLab.

And they’ve uploaded a patch. And it works!

Instructions:

  1. Visit https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3877, download gnome-shell_3.38.3-3ubuntu1_3.38.3-3ubuntu2.patch and move it to your /etc/nixos/ folder.
  2. Place the following in your /etc/nixos/configuration.nix:
nixpkgs = {
  overlays = [
    (self: super: {
      gnome = super.gnome.overrideScope' (selfg: superg: {
        gnome-shell = superg.gnome-shell.overrideAttrs (old: {
          patches = (old.patches or []) ++ [
            (pkgs.substituteAll {
              src = ./gnome-shell_3.38.3-3ubuntu1_3.38.3-3ubuntu2.patch;
            })
          ];
        });
      });
    })
  ];
};

services.xserver.desktopManager.gnome.extraGSettingsOverrides = ''
[com.ubuntu.login-screen]
background-repeat='no-repeat'
background-size='cover'
background-color='#777777'
background-picture-uri='file:///etc/nixos/background.jpg'
'';
  1. Adjust the above background-picture-uri to point to your background. (I put my background at /etc/nixos/background.jpg.)

The great thing about this patch is that it stores the settings in dconf/gsettings, which means that you don’t have to re-compile GNOME Shell every time you want to change your background. Just update your extraGSettingsOverrides and run nixos-rebuild switch` again.

If you’re bothered by having the word “Ubuntu” in your NixOS build, simply rename the settings in the patch.

3 Likes