SDDM Background on Default Theme

Hi! I’m a new NixOS user. I’ve been trying to figure out how to set the background image for SDDM. From initial research, everyone says to package a custom theme and point services.displayManager.sddm.theme to that derivation.

However, I actually like the default (breeze?) theme for SDDM. Can I change the background image for this default theme? Arch Wiki says to put a file called theme.conf.user in the same theme directory (which my system tells me is /run/current-system/sw/share/sddm/themes/breeze, but I’m sure is in reality somewhere in the Nix store), but I can’t quite figure out how to do that.

I believe my question boils down to the following: Is a custom SDDM theme required to configure the background image in NixOS? And, as a bonus question, is it possible to modify the default breeze SDDM theme somehow?

Thanks for your time!

You can drop that theme.conf.user file in the right place by creating a package that contains that file at the right location. The easiest way is with pkgs.writeTextDir, which is what I do.

environment.systemPackages = [
  (pkgs.writeTextDir "share/sddm/themes/breeze/theme.conf.user" ''
    [General]
    background=${pkgs.kdePackages.plasma-workspace-wallpapers}/share/wallpapers/MilkyWay/contents/images/5120x2880.png
  '')
];
5 Likes

Wow, super simple! Thanks a ton.

A note for anyone trying this at home: this method doesn’t like a raw path set for background (I tried /home/(user)/path/to/wallpaper.png) but all I got was a white screen.

If you want a custom file as your background, you can try what worked for me: create a derivation that just copies the wallpaper file to the Nix store.

Here’s my code:

let
  background-package = pkgs.stdenvNoCC.mkDerivation {
    name = "background-image";
    src = ./.;
    dontUnpack = true;
    installPhase = ''
      cp $src/wallpaper.png $out
    '';
  };
in
{
  #services.xserver.enable = true;
  services.displayManager.sddm = {
    enable = lib.mkDefault true;
    theme = "breeze";
    wayland.enable = true;
  };

  environment.systemPackages = [
    (
      pkgs.writeTextDir "share/sddm/themes/breeze/theme.conf.user" ''
        [General]
        background = ${background-package}
      ''
    )
  ];
}

This worked for me.

  1. Place you wallpaper to the same folder where nix config is present
  2. Name is as wallpaper.jpg or you image type.
  3. Configure the nix file as below

let
  # Define the custom background package with the correct relative path
  background-package = pkgs.stdenvNoCC.mkDerivation {
    name = "background-image";
    src = ./wallpaper.jpg;  # Place wallpaper.jpg in the same directory as this config file
    dontUnpack = true;
    installPhase = ''
      cp $src $out
    '';
  };
  
in {
# X11 and KDE Plasma configuration
  services.xserver.enable = true;
  services.displayManager.sddm = {
    enable = lib.mkDefault true;
    theme = "breeze";
    wayland.enable = true;
  };
environment.systemPackages = with pkgs; [
    (pkgs.writeTextDir "share/sddm/themes/breeze/theme.conf.user" ''
      [General]
      background = "${background-package}"
    '')
];

}

Thanks! First quick solution that I found to this issue.

The background-image derivation can be shortened to:

pkgs.runCommand "background-image" {} ''
  cp ${./wallpaper.jpg} $out
'';