How do I apply an custom theme to SDDM?

I want to use the dialog theme for my SDDM. The only mention I found on the forum to this problem was this and I didn’t quite get it. Can anybody explain what I have to do? I didn’t wanted to necrobump the other topic.

I’m assuming SDDM theming is impossible, so the issue can be closed.

It can be done using the options services.xserver.displayManager.sddm.theme. You’ll need to package the theme yourself, then add it to your packages.

Here is an example of an sddm theme package from the thread you mentioned: nixos-config/nixpkgs/pkgs/sddm-themes.nix at michaelpj/nixos-config · GitHub

Can you explain how can I add a custom script as a theme? Also, are SDDM theme packages allowed to enter the official Nix package base? Because if I’m going to package it I would like to share that with everyone.

I’m not sure what you mean by a custom script. The link I shared with you should show how you can make the package. You can add this package to your system by adding something like this to your configuration:

environment.systemPackages = with pkgs; [
    (callPackage ./path/to/package.nix)
];

SDDM themes should be allowed. I don’t know if any are currently packaged, but there are plenty of other types of themes available, so I don’t see why not.

Thank you very much! I’ll try them!

Good luck! Feel free to ask if you have any trouble packaging it.

Ok, I have hit a wall,
here is how my sddm-theme-dialog.nix looks like:

{ stdenv, fetchFromGitHub }:
{
  sddm-theme-dialog = stdenv.mkDerivation rec {
    pname = "sddm-theme-dialog";
    version = "53f81e3";
    dontBuild = true;
    installPhase = ''
      mkdir -p $out/share/sddm/themes
      cp -aR $src $out/share/sddm/themes/sddm-theme-dialog
    '';
    src = fetchFromGitHub {
      owner = "joshuakraemer";
      repo = "sddm-theme-dialog";
      rev = "53f81e322f715d3f8e3f41c38eb3774b1be4c19b";
      sha256 = "qoLSRnQOvH3rAH+G1eRrcf9ZB6WlSRIZjYZBOTkew/0=";
    };
  };
}

And yes rev and sha is correct. I got them with nix-prefetch-github joshuakraemer sddm-theme-dialog I added the following line to my packages list in nix config: /home/myusername/Downloads/sddm-theme-dialog.nix

But it gives me the following error:

error: A definition for option `users.users.myusername.packages."[definition 1-entry 10]"' is not of type `package'. Definition values:
       - In `/etc/nixos/configuration.nix': /home/myusername/Downloads/sddm-themes.nix

What to do now?

The line you added to your packages is incorrect, you need to use callPackage as I showed in my other comment. I’m not sure it will work when installed as a per user package, you might need to use environment.systemPackages like I showed.

Sorry for the first confusion.

With:

  environment.systemPackages = with pkgs; [
    (callPackage /home/myusername/Downloads/sddm-theme-dialog.nix)
  ];

Error has changed to:

error: A definition for option `environment.systemPackages."[definition 1-entry 1]"' is not of type `package'. Definition values:
       - In `/etc/nixos/configuration.nix': <function>

Perhaps there is a problem with the file?

callPackage requires a second argument. The overrides you want to pass. Most of the time its just the empty set.

You got it boss:

  environment.systemPackages = with pkgs; [
    (callPackage /home/myusername/Downloads/sddm-theme-dialog.nix {})
  ];
error: A definition for option `environment.systemPackages."[definition 1-entry 1]"' is not of type `package'. Definition values:
       - In `/etc/nixos/configuration.nix':
           {
             override = <function, args: {fetchFromGitHub, stdenv}>;
             overrideDerivation = <function>;
             sddm-theme-dialog = <derivation sddm-theme-dialog-53f81e3>;
           }

I haven’t looked at the callPackaged expression first, but now.

It would work with (callPackage /home/myusername/Downloads/sddm-theme-dialog.nix {}).sddm-theme-dialog.

2 Likes

That did it! Although now it only shows the virtual keyboard for some reason…
Also for getting this to nix repo, I just have to follow this right?

Yep, reading the contribution section should tell you what you need. I would recommend changing your package expression slightly before adding, you don’t need the sddm-theme-dialog =. This is also why you needed (callPackage /home/myusername/Downloads/sddm-theme-dialog.nix {}).sddm-theme-dialog instead of just (callPackage /home/myusername/Downloads/sddm-theme-dialog.nix {}).

{ stdenv, fetchFromGitHub }:
{
  stdenv.mkDerivation rec {
    pname = "sddm-theme-dialog";
    version = "53f81e3";
    dontBuild = true;
    installPhase = ''
      mkdir -p $out/share/sddm/themes
      cp -aR $src $out/share/sddm/themes/sddm-theme-dialog
    '';
    src = fetchFromGitHub {
      owner = "joshuakraemer";
      repo = "sddm-theme-dialog";
      rev = "53f81e322f715d3f8e3f41c38eb3774b1be4c19b";
      sha256 = "qoLSRnQOvH3rAH+G1eRrcf9ZB6WlSRIZjYZBOTkew/0=";
    };
  };
}