Override default lightdm-gtk-greeter.conf in configuration.nix

To date, attempts to add parameters to configuration.nix to override the default lightdm greeter appearance have resulted in error messages about non-existent definitions or failing to rebuild with the session dropping to the login screen.

It has been possible to directly modify the /nix/store lightdm-gtk-greeter.conf settings at the end of the symlink chain to obtain the general appearance desired, but these parameters are lost with a system update and I want to configure NixOS to override the default, even after an update.

Here is an example of a working .conf file contents without the background, theme and icon specifics:

[greeter]
background = /path/to/whatever
theme-name = whatever theme name
icon-theme-name = whatever icon theme
indicators = ~session;~host;~clock
position = 87%,center
user-background = false
hide-user-image = true

These parameters function when the /nix/store .conf file is directly modified, but need to know how, specifically, to modify configuration.nix to override the default and maintain the custom appearance after updates.

Additionally, a custom icon set and custom theme are being used, and neither is a part of the Nixos mate desktop installation. They are located at ‘/home//$USER.icons’ and ‘/home/$USER/.themes’, respectively. I would like to know how to install them into Nixos to that they are retained after updates and can be used in configuration for lightdm-gtk-greeter.conf. Presently it appears that only installed themes can be used to customize the lightdm greeter.

Thank you.

What did you try and what was the error message you got?

Here is what was initially tried:

 services.xserver.displayManager.lightdm = {
    enable = true;
    greeter = {
      # Path to the greeter configuration file.
      config = {
        background = "/path/to/whatever";
        theme-name = "whatever";
        icon-theme-name = "whatever";
        indicators = "~session;~host;~clock";
        position = "87%,center";
        user-background = false;
        hide-user-image = true;
        # Uncomment the line below if you want to set a default user image
        # default-user-image = "";
      };
    };
  };

Upon rebuild a series of error messages indicating the config = parameter was not a valid definition and failure to complete rebuild.

In general it is quite helpful if you post the actual error (complete) rather than your own interpretation.

sudo nixos-rebuild switch  --show-trace
error:
       … while evaluating the attribute 'config'
         at /nix/store/5k44dj4j6xqqkv40lj8nryamk5wkja7f-nixos-23.11/nixos/lib/modules.nix:320:9:
          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          321|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/5k44dj4j6xqqkv40lj8nryamk5wkja7f-nixos-23.11/nixos/lib/modules.nix:320:18:
          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          321|         _module = checked (config._module);

       … while calling the 'throw' builtin
         at /nix/store/5k44dj4j6xqqkv40lj8nryamk5wkja7f-nixos-23.11/nixos/lib/modules.nix:296:18:
          295|                     ''
          296|             else throw baseMsg
             |                  ^
          297|         else null;

       error: The option `services.xserver.displayManager.lightdm.greeter.hide-user-image' does not exist. Definition values:
       - In `/etc/nixos/configuration.nix': true
Command 'nix-build '<nixpkgs/nixos>' --attr config.system.build.nixos-rebuild --show-trace --no-out-link' returned non-zero exit status 1.

It should be greeters I guess: https://search.nixos.org/options?channel=25.11&query=services.xserver.displayManager.lightdm.greeters

Edit: no it’s not.

Note that in the past there have been error messages for everything from background to hide-user-image.

Ok I was too quick. Maybe have a look at what options you have here: https://search.nixos.org/options?channel=25.11&query=services.xserver.displayManager.lightdm

Could it be that everything has to go into extraConfig? https://search.nixos.org/options?channel=25.11&show=services.xserver.displayManager.lightdm.extraConfig&query=services.xserver.displayManager.lightdm

Changed to greeters:

  services.xserver.displayManager.lightdm = {
    enable = true;
    greeters = {
      # Path to the greeter configuration file.
      config = {

error:
… while evaluating the attribute ‘config’
at /nix/store/5k44dj4j6xqqkv40lj8nryamk5wkja7f-nixos-23.11/nixos/lib/modules.nix:320:9:
319| options = checked options;
320| config = checked (removeAttrs config [ “_module” ]);
| ^
321| _module = checked (config._module);

   … while calling the 'seq' builtin
     at /nix/store/5k44dj4j6xqqkv40lj8nryamk5wkja7f-nixos-23.11/nixos/lib/modules.nix:320:18:
      319|         options = checked options;
      320|         config = checked (removeAttrs config [ "_module" ]);
         |                  ^
      321|         _module = checked (config._module);

   … while calling the 'throw' builtin
     at /nix/store/5k44dj4j6xqqkv40lj8nryamk5wkja7f-nixos-23.11/nixos/lib/modules.nix:296:18:
      295|                     ''
      296|             else throw baseMsg
         |                  ^
      297|         else null;

   error: The option `services.xserver.displayManager.lightdm.greeters.config' does not exist. Definition values:
   - In `/etc/nixos/configuration.nix':
       {
         background = "/path/to whatever";
         hide-user-image = true;
         icon-theme-name = "whatevere";
         indicators = "~session;~host;~clock";
       ...

Command ‘nix-build ‘<nixpkgs/nixos>’ --attr config.system.build.nixos-rebuild --show-trace --no-out-link’ returned non-zero exit status 1.

Trying this:

services.xserver.displayManager.lightdm = {
    enable = true;

    # All greeter config moved into extraConfig
    extraConfig = ''
      background=/path/to/whatever
      theme-name=whatever
      icon-theme-name=whatever
      indicators=~session;~host;~clock
      position=87%,center
      user-background=false
      hide-user-image=true
      # default-user-image=
    '';
  };

Sorry that I confused you. I was too quick with my answer. See my latest: Override default lightdm-gtk-greeter.conf in configuration.nix - #9 by eblechschmidt

In case it crashes the session, won’t be back for a while.

Takes this and just replace config with extraConfig I think that should do the trick. I’m on my phone so I might be overlooking something scrolling back and forth.

Still rebuilding the configuration, should know either after crash or reboot. Thanks for the input.

Rebuild with this configuration crashes the session down to the login screen and relogin shows desktop malfunction requiring reboot:

services.xserver.displayManager.lightdm = {
    enable = true;

    # All greeter config moved into extraConfig
    extraConfig = ''
      background=/path/to/whatever
      theme-name=whatever
      icon-theme-name=whatever
      indicators=~session;~host;~clock
      position=87%,center
      user-background=false
      hide-user-image=true
      # default-user-image=
    '';
  };
services.xserver.displayManager.lightdm = {
    enable = true;
    greeter = {
      # Path to the greeter configuration file.
      extraConfig = {
        background = "/path/to/whatever";
        theme-name = "whatever";
        icon-theme-name = "whatever";
        indicators = "~session;~host;~clock";
        position = "87%,center";
        user-background = false;
        hide-user-image = true;
        # Uncomment the line below if you want to set a default user image
        # default-user-image = "";
      };
    };
  };

I think this should be correct. Again I’m on the road and I’m not sure if I got it correctly on my small phone screen. Please also take a look at because I think it is what you are looking for: https://search.nixos.org/options?channel=25.11&show=services.xserver.displayManager.lightdm.extraConfig&query=services.xserver.displayManager.lightdm

Rebuild generated the following error:

error: The option `services.xserver.displayManager.lightdm.greeter.extraConfig' does not exist. Definition values:
       - In `/etc/nixos/configuration.nix':
           {
             background = "/usr/share/backgrounds/wallpaper/snow_aurora.jpeg";
             hide-user-image = true;
             icon-theme-name = "Ambiant-MATE";
             indicators = "~session;~host;~clock";
           ...
Command 'nix-build '<nixpkgs/nixos>' --attr config.system.build.nixos-rebuild --show-trace --no-out-link' returned non-zero exit status 1.
nixos-option services.xserver.displayManager.lightdm

This attribute set contains:
autoLogin
background
enable
extraConfig
extraSeatDefaults
greeter
greeters

Other than "background" it appears that everything else should go in "extraConfig"
Explanation of Key Options:

autoLogin: This option can be used to enable automatic login for a user.

background: This is a top-level option, and it should be configured directly under services.xserver.displayManager.lightdm.

enable: This is to enable or disable the LightDM display manager.

extraConfig: This is for any custom LightDM configuration options that are not exposed by NixOS’s structured configuration (like theme-name, indicators, etc.).

greeter: This section is for configuring the greeter (the login screen UI), and it will contain options like theme (if structured in your version), language, or layout.

greeters: This seems to be related to multiple greeter support (e.g., lightdm-webkit or other greeters), and generally, this would be used to define more than one greeter option.