sddm-astronaut-theme icon indicating copy to clipboard operation
sddm-astronaut-theme copied to clipboard

Packaging theme for NixOS

Open maotseantonio opened this issue 11 months ago • 25 comments

maotseantonio avatar Jan 05 '25 15:01 maotseantonio

I'll probably pack it for nixos soon.

Edit:

Current solution https://github.com/Keyitdev/sddm-astronaut-theme/issues/17#issuecomment-2610888161

Keyitdev avatar Jan 05 '25 17:01 Keyitdev

Hey @Keyitdev, I would also really like this packaged for NixOS. The Catppuccin SDDM theme does it too, so maybe that could be a good starting point? The package/installation details are here.

I am no Nix expert by any means but if you need any help, maybe I can be of assistance :smiley:

MasterEvarior avatar Jan 07 '25 15:01 MasterEvarior

For anyone interested in using this amazing set of themes on NixOS: while we wait for proper support from someone who knows what they are doing, I managed to create a derivation and use it in my setup after a few hours of trial and error. You can check out the derivation and how I use it in my config.

This is my first time creating a proper derivation, so I don’t fully understand how it works - but it does! Note that the on screen keyboard doesn’t seem to function. Feel free to use my work for actual packaging or further improvements.

xhos avatar Jan 12 '25 17:01 xhos

For anyone interested in using this amazing set of themes on NixOS: while we wait for proper support from someone who knows what they are doing, I managed to create a derivation and use it in my setup after a few hours of trial and error. You can check out the derivation and how I use it in my config.

This is my first time creating a proper derivation, so I don’t fully understand how it works - but it does! Note that the on screen keyboard doesn’t seem to function. Feel free to use my work for actual packaging or further improvements.

I have expanded on that a little bit and written a nix module with an enable option and an option to choose the theme. My version of module + derivation can be found here and how to use it here.

(The module also automatically adds the dependencies for sddm)

Computerdores avatar Jan 17 '25 16:01 Computerdores

I came up with something like this. Can someone test it? configuration.nix

environment.systemPackages = with pkgs; [
  (pkgs.callPackage ./sddm-astronaut-theme.nix {
    theme = "black_hole";
    themeConfig = {
      General = {
        HeaderText = "Hi";
        Background = "/home/user/Desktop/wp.png";
        FontSize = "10.0";
      };
    };
  })
];

sddm-astronaut-theme.nix

{
  stdenvNoCC,
  qt6,
  lib,
  fetchFromGitHub,
  formats,
  theme ? "astronaut",
  themeConfig ? null,
}: 
let
  overwriteConfig = (formats.ini {}).generate "${theme}.conf.user" themeConfig;
in
  stdenvNoCC.mkDerivation rec {
    name = "sddm-astronaut-theme";

    src = fetchFromGitHub {
      owner = "Keyitdev";
      repo = "sddm-astronaut-theme";
      rev = "11c0bf6147bbea466ce2e2b0559e9a9abdbcc7c3";
      hash = "sha256-gBSz+k/qgEaIWh1Txdgwlou/Lfrfv3ABzyxYwlrLjDk=";
    };

    propagatedUserEnvPkgs = with qt6; [qtsvg qtvirtualkeyboard qtmultimedia];

    dontBuild = true;

    dontWrapQtApps = true;

    installPhase = ''
      themeDir="$out/share/sddm/themes/${name}"

      mkdir -p $themeDir
      cp -r $src/* $themeDir

      install -dm755 "$out/share/fonts"
      cp -r $themeDir/Fonts/* $out/share/fonts/

      # Update metadata.desktop to load the chosen theme.
      substituteInPlace "$themeDir/metadata.desktop" \
        --replace-fail "ConfigFile=Themes/astronaut.conf" "ConfigFile=Themes/${theme}.conf"

      # Create theme.conf.user of the selected theme. To overwrite its configuration.
      ${lib.optionalString (lib.isAttrs themeConfig) ''
        install -dm755 "$themeDir/Themes"
        cp ${overwriteConfig} $themeDir/Themes/${theme}.conf.user
        ''}
    '';

    meta = with lib; {
      description = "Series of modern looking themes for SDDM";
      homepage = "https://github.com/Keyitdev/sddm-astronaut-theme";
      license = licenses.gpl3;
      platforms = platforms.linux;
    };
  }

Keyitdev avatar Jan 18 '25 00:01 Keyitdev

It doesn't work out of the box for me, but knowing what I know from doing it myself I was able to fix it with these changes to configuration.nix:

services.displayManager.sddm = {
        theme = "sddm-astronaut-theme";
        extraPackages = with pkgs; [
            kdePackages.qtmultimedia
            kdePackages.qtsvg
            kdePackages.qtvirtualkeyboard
        ];
};

I would also suggest making this change in sddm-astronaut-theme.nix:

- themeDir="$out/share/sddm/themes/${name}"
+ themeDir="$out/share/sddm/themes/astronaut"

This way selecting the theme in configuration.nix would instead look like this:

- services.displayManager.sddm.theme = "sddm-astronaut-theme";
+ services.displayManager.sddm.theme = "astronaut";

(because having sddm and theme in there when we are setting the theme for sddm seems redundant)

Computerdores avatar Jan 18 '25 11:01 Computerdores

Having to set services.displayManager.sddm.extraPackages could be fixed by wrapping the derivation in a module like I did here (although that module does currently lack the functionality of setting a custom theme, as I am currently patching the theme in the derivation instead)

Computerdores avatar Jan 18 '25 12:01 Computerdores

Yeah, but shoudn't propagatedUserEnvPkgs solve this problem? We can try also something like this https://github.com/xhos/nixdots/blob/a5e5442e9aaf48ef796d16f43ad8a62596f1bdba/derivs/sddm-astronaut-theme.nix#L56-L62 And Idk whats the difference between kdePackages and qt6. I slightly changed this guy's code and it works for me:

environment.systemPackages = with pkgs; [
    (pkgs.callPackage ./sddm-astronaut-theme.nix {
        theme = "black_hole";
	themeConfig={
	    General = {
		    HeaderText ="Hi";
            Background="/home/user/Desktop/wp.png";
            FontSize="10.0";
	        };	
	    };
      })
    ];

    services.displayManager.sddm = {
      enable = true;
      package = pkgs.kdePackages.sddm;
      theme = "sddm-astronaut-theme";
    };
{
  stdenvNoCC,
  qt6,
  #kdePackages,
  lib,
  fetchFromGitHub,
  formats,
  theme ? "astronaut",
  themeConfig ? null,
}: 
let
  overwriteConfig = (formats.ini {}).generate "${theme}.conf.user" themeConfig;
in
  stdenvNoCC.mkDerivation rec {
    name = "sddm-astronaut-theme";

    src = fetchFromGitHub {
      owner = "Keyitdev";
      repo = "sddm-astronaut-theme";
      rev = "11c0bf6147bbea466ce2e2b0559e9a9abdbcc7c3";
      hash = "sha256-gBSz+k/qgEaIWh1Txdgwlou/Lfrfv3ABzyxYwlrLjDk=";
    };

    propagatedBuildInputs = [
        qt6.qtsvg
        qt6.qtmultimedia
        qt6.qtvirtualkeyboard
    ];

    propagatedUserEnvPkgs = with qt6; [qtsvg qtvirtualkeyboard qtmultimedia];

    dontBuild = true;

    dontWrapQtApps = true;

    installPhase = ''
      themeDir="$out/share/sddm/themes/${name}"

      mkdir -p $themeDir
      cp -r $src/* $themeDir

      install -dm755 "$out/share/fonts"
      cp -r $themeDir/Fonts/* $out/share/fonts/

      # Update metadata.desktop to load the chosen theme.
      substituteInPlace "$themeDir/metadata.desktop"        --replace-fail "ConfigFile=Themes/astronaut.conf" "ConfigFile=Themes/${theme}.conf"

      # Create theme.conf.user of the selected theme. To overwrite its configuration.
      ${lib.optionalString (lib.isAttrs themeConfig) ''
        install -dm755 "$themeDir/Themes"
        cp ${overwriteConfig} $themeDir/Themes/${theme}.conf.user
        ''}
    '';

      # Propagate Qt6 libraries to user environment
#      postFixup = ''
#        mkdir -p $out/nix-support
#        echo ${qt6.qtsvg} >> $out/nix-support/propagated-user-env-packages
#        echo ${qt6.qtmultimedia} >> $out/nix-support/propagated-user-env-packages
#        echo ${qt6.qtvirtualkeyboard} >> $out/nix-support/propagated-user-env-packages
#      '';

    meta = with lib; {
      description = "Series of modern looking themes for SDDM";
      homepage = "https://github.com/Keyitdev/sddm-astronaut-theme";
      license = licenses.gpl3;
      platforms = platforms.linux;
    };
  }

Keyitdev avatar Jan 18 '25 12:01 Keyitdev

Yeah, but shoudn't propagatedUserEnvPkgs solve this problem?

I don't know if it should fix that issue, I only know that it doesn't for me.

(I have tried propagatedBuildInputs, buildInputs, propagatedUserEnvPkgs, and echoing into $out/nix-support/propagated-user-env-packages - neither fixed that issue for me, while adding the packages to services.displayManager.sddm.extraPackages did.)

We can try also something like this https://github.com/xhos/nixdots/blob/a5e5442e9aaf48ef796d16f43ad8a62596f1bdba/derivs/sddm-astronaut-theme.nix#L56-L62 And Idk whats the difference between kdePackages and qt6. I slightly changed this guy's code and it works for me:

I have tried your updated version both with and without uncommenting the postFixup step and I still get the issue.

(Note: I have also cleaned up my version and removed the custom patching business I had in there in favor of your approach with the ${theme}.conf.user)

Computerdores avatar Jan 18 '25 13:01 Computerdores

Yeah, but shoudn't propagatedUserEnvPkgs solve this problem?

I don't know if it should fix that issue, I only know that it doesn't for me.

(I have tried propagatedBuildInputs, buildInputs, propagatedUserEnvPkgs, and echoing into $out/nix-support/propagated-user-env-packages - neither fixed that issue for me, while adding the packages to services.displayManager.sddm.extraPackages did.)

We can try also something like this https://github.com/xhos/nixdots/blob/a5e5442e9aaf48ef796d16f43ad8a62596f1bdba/derivs/sddm-astronaut-theme.nix#L56-L62 And Idk whats the difference between kdePackages and qt6. I slightly changed this guy's code and it works for me:

I have tried your updated version both with and without uncommenting the postFixup step and I still get the issue.

(Note: I have also cleaned up my version and removed the custom patching business I had in there in favor of your approach with the ${theme}.conf.user)

For some reasons using propagatedUserEnvPkgs doesn't fix the issue for me as well

Ate329 avatar Jan 18 '25 13:01 Ate329

@Computerdores I tried yours exactly as explained but I get this error whilst building sddm-wrapped

Error: detected mismatched Qt dependencies:
    /nix/store/d7f3ryzq9fkp3gp4faplqlchlfdg9n9d-qtbase-6.8.1
    /nix/store/rriq96lra5fa2fm91q9c2zdswfk05pqi-qtbase-5.15.16-dev

jasper-clarke avatar Jan 23 '25 06:01 jasper-clarke

The version of it that's available on nixpkgs currently is broken (see: https://github.com/NixOS/nixpkgs/issues/374821#issuecomment-2610696821). It says the module qtmultimedia is missing but it's included. It was working before this commit 🤔

NovaViper avatar Jan 23 '25 19:01 NovaViper

For everyone, something different works :\ This should work: configuration.nix

environment.systemPackages = with pkgs; [
    (pkgs.callPackage ./sddm-astronaut-theme.nix {
        theme = "black_hole";
	themeConfig={
	    General = {
	    HeaderText ="Hi";
            Background="/home/user/Desktop/wp.png";
            FontSize="10.0";
	        };	
	    };
      })
    ];

services.displayManager.sddm = {
      enable = true;
      package = pkgs.kdePackages.sddm;
      theme = "sddm-astronaut-theme";
};

ANOTHER version of configuration.nix if you get an error that something is not installed (but it's not a real solution to the problem).

environment.systemPackages = with pkgs; [
    (pkgs.callPackage ./sddm-astronaut-theme.nix {
        theme = "black_hole";
	themeConfig={
	    General = {
	    HeaderText ="Hi";
            Background="/home/user/Desktop/wp.png";
            FontSize="10.0";
	        };	
	    };
      })
    ];

services.displayManager.sddm = {
        enable = true;
        package = pkgs.kdePackages.sddm;
        theme = "sddm-astronaut-theme";
        extraPackages = with pkgs; [
            kdePackages.qtmultimedia
            kdePackages.qtsvg
            kdePackages.qtvirtualkeyboard
        ];
};

sddm-astronaut-theme.nix

{
  stdenvNoCC,
  qt6,
  lib,
  fetchFromGitHub,
  formats,
  theme ? "astronaut",
  themeConfig ? null,
}: 
let
  overwriteConfig = (formats.ini {}).generate "${theme}.conf.user" themeConfig;
in
  stdenvNoCC.mkDerivation rec {
    name = "sddm-astronaut-theme";

    src = fetchFromGitHub {
      owner = "Keyitdev";
      repo = "sddm-astronaut-theme";
      rev = "11c0bf6147bbea466ce2e2b0559e9a9abdbcc7c3";
      hash = "sha256-gBSz+k/qgEaIWh1Txdgwlou/Lfrfv3ABzyxYwlrLjDk=";
    };

    propagatedUserEnvPkgs = with qt6; [qtsvg qtvirtualkeyboard qtmultimedia];

    dontBuild = true;

    dontWrapQtApps = true;

    installPhase = ''
      themeDir="$out/share/sddm/themes/${name}"

      mkdir -p $themeDir
      cp -r $src/* $themeDir

      install -dm755 "$out/share/fonts"
      cp -r $themeDir/Fonts/* $out/share/fonts/

      # Update metadata.desktop to load the chosen theme.
      substituteInPlace "$themeDir/metadata.desktop" \
        --replace-fail "ConfigFile=Themes/astronaut.conf" "ConfigFile=Themes/${theme}.conf"

      # Create theme.conf.user of the selected theme. To overwrite its configuration.
      ${lib.optionalString (lib.isAttrs themeConfig) ''
        install -dm755 "$themeDir/Themes"
        cp ${overwriteConfig} $themeDir/Themes/${theme}.conf.user
        ''}
    '';

    meta = with lib; {
      description = "Series of modern looking themes for SDDM";
      homepage = "https://github.com/Keyitdev/sddm-astronaut-theme";
      license = licenses.gpl3;
      platforms = platforms.linux;
    };
  }

I am using NixOS 24.11. The problem is definitely with installing dependencies. Having to set services.displayManager.sddm.extraPackages could be fixed by wrapping the derivation in a module like someone did here. But imo it's not a real solution, and makes package unnecessarily complicated. @IronGreninja I took most of the code from you, changed symlink to copy, can you help debug what's wrong?

Keyitdev avatar Jan 23 '25 19:01 Keyitdev

@Keyitdev Can confirm that adding the depedent packages to services.displayManager.sddm.extraPackage makes the package work properly!

    services.displayManager.sddm = {
      enable = true;
      autoNumlock = true;
      enableHidpi = true;
      wayland.enable = true;
      extraPackages = with pkgs; [
        kdePackages.qtsvg
        kdePackages.qtmultimedia
        kdePackages.qtvirtualkeyboard
      ];
    };

NovaViper avatar Jan 23 '25 20:01 NovaViper

@Keyitdev Can confirm on NixOS 25.05 (unstable) your method is working perfectly. Specifically the second version of the configuration.nix in your message due to what @NovaViper mentioned above.

jasper-clarke avatar Jan 23 '25 20:01 jasper-clarke

Since it is already in nixpkgs, I had deleted my PR. But it seems it's broken there. The following override works on my machine. Putting the dependencies in propagatedUserEnvPkgs seems to be the right way. Otherwise, it errors with qtmultimedia cannot be found.

environment.systemPackages = let
in [
  ((pkgs.sddm-astronaut.override {
      embeddedTheme = "hyprland_kath";
      themeConfig = {
        FontSize = 20;
      };
    })
    .overrideAttrs (prev: {
      propagatedUserEnvPkgs = prev.propagatedBuildInputs;
      propagatedBuildInputs = [];

      installPhase =
        prev.installPhase
        + ''

          themeDir="$out/share/sddm/themes/sddm-astronaut-theme"

          mkdir -p $out/share/fonts
          ln -s $out/share/sddm/themes/sddm-astronaut-theme/Fonts/* $out/share/fonts/
        '';
    }))
];

IronGreninja avatar Jan 24 '25 16:01 IronGreninja

@IronGreninja
Yeah, but the current package in nixpkgs is broken, as you said. That is why I am trying to create an official package. Both have similar problems with dependencies.

Package in nixos repos uses propagatedBuildInputs. And you say that changing it to propagatedUserEnvPkgs solves the issue for you. But in my version propagatedUserEnvPkgs is already used and some people say it still doesn't work (it works for me).

Keyitdev avatar Jan 24 '25 17:01 Keyitdev

uh, i have managed to make sddm work with @Keyitdev iteration, if i change the theme and rebuild i can see the settings of SDDM change. However, and this is strange there is no background. Am i doing something wrong? should i manually set it with this line? Background="/home/user/Desktop/wp.png"; I tried to modify to a path were i have a wallpaper, but it doesnt seem to work.

Also i had to use wayland-enable=true to avoid starting an Xserver just for SDDM since i'm using hyprland, but even with xserver i had the same result

Sorry if i sound silly.

fuma-afk avatar Mar 25 '25 10:03 fuma-afk

@fuma-afk These lines are just an example showing how to write code syntax.

themeConfig={
	General = {
	    HeaderText ="Hi";
            Background="/home/user/Desktop/wp.png";
            FontSize="10.0";
	};
 };

You should manually set the background or you can just delete this line and use default.

Keyitdev avatar Mar 25 '25 10:03 Keyitdev

Yes i realized as soon as i posted that i had to "rebuild" the conf file using that syntax as i changed the font. My bad and thank you for the reply

fuma-afk avatar Mar 25 '25 12:03 fuma-afk

In case this helps anyone, I got it working with the included themes on NixOS like this

vanilla_theme = builtins.fromTOML(builtins.readFile "${pkgs.sddm-astronaut}/share/sddm/themes/sddm-astronaut-theme/Themes/black_hole.conf"); ## whatever theme file you want
    theme = vanilla_theme.General;

    sddm-astronaut = pkgs.sddm-astronaut.override {
      themeConfig = theme;
    };

I mostly made it its own var so I could override some of the attributes after it loaded the file. Hope that helps anyone!

adamzwakk avatar Apr 05 '25 21:04 adamzwakk

For info. this works for me in configuration.nix

services.displayManager = {
    sddm = {
      enable = true;
      package = pkgs.kdePackages.sddm;   # required to prevent version error
      wayland.enable = true;
      theme = "sddm-astronaut-theme";
      extraPackages = with pkgs.kdePackages; [
        qtsvg
	qtmultimedia
	qtvirtualkeyboard
      ];
    };
  };

In the nix configuration file I didn't need any buildInputs, propagatedBuildInputs, propagatedUserEnvPkgs etc. Just simply copy the files to $out as per the original file.

b7031719 avatar May 17 '25 20:05 b7031719

For some reason while @Keyitdev 's version works for me, I get an error reading any wallpaper I try to use, whether it's jpg or png or whatever. I'm not sure it's related as it happens if I use other display managers like LightDM as well but I thought it might bear mentioning.

syelan34 avatar May 21 '25 00:05 syelan34