Packaging theme for NixOS
I'll probably pack it for nixos soon.
Edit:
Current solution https://github.com/Keyitdev/sddm-astronaut-theme/issues/17#issuecomment-2610888161
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:
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.
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)
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;
};
}
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)
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)
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;
};
}
Yeah, but shoudn't
propagatedUserEnvPkgssolve 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)
Yeah, but shoudn't
propagatedUserEnvPkgssolve 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 toservices.displayManager.sddm.extraPackagesdid.)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
@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
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 🤔
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 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
];
};
@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.
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
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).
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 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.
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
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!
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.
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.