Skip to content

Instantly share code, notes, and snippets.

@BBArikL
Last active April 11, 2025 01:15
Show Gist options
  • Save BBArikL/b389c4592d636380523e03ac423b77b3 to your computer and use it in GitHub Desktop.
Save BBArikL/b389c4592d636380523e03ac423b77b3 to your computer and use it in GitHub Desktop.
wallpaper-engine-kde-plugin on NixOS
{ config, lib, pkgs, ...}:
let
# References: https://github.com/xerhaxs/nixos/blob/main/nixosModules/pkgs/wallpaper-engine-kde-plugin.nix and https://discourse.nixos.org/t/wallpaper-engine-on-nixos-wallpaper-engine-kde-plugin/19744/25
glslang-submodule = with pkgs; stdenv.mkDerivation {
name = "glslang";
installPhase = ''
mkdir -p $out
'';
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "glslang";
rev = "c34bb3b6c55f6ab084124ad964be95a699700d34";
sha256 = "IMROcny+b5CpmzEfvKBYDB0QYYvqC5bq3n1S4EQ6sXc=";
};
};
wallpaper-engine-kde-plugin = with pkgs; stdenv.mkDerivation rec {
pname = "wallpaperEngineKde";
version = "96230de92f1715d3ccc5b9d50906e6a73812a00a";
src = fetchFromGitHub {
owner = "Jelgnum";
repo = "wallpaper-engine-kde-plugin";
rev = version;
hash = "sha256-vkWEGlDQpfJ3fAimJHZs+aX6dh/fLHSRy2tLEsgu/JU=";
fetchSubmodules = true;
};
nativeBuildInputs = [
cmake
kdePackages.extra-cmake-modules
glslang-submodule
pkg-config
gst_all_1.gst-libav
shaderc
ninja
];
buildInputs = [
mpv
lz4
vulkan-headers
vulkan-tools
vulkan-loader
]
++ (with kdePackages; with qt6Packages; [
qtbase
qt6.full
kpackage
kdeclarative
libplasma
qtwebsockets
qtwebengine
qtwebchannel
qtmultimedia
qtdeclarative
])
++ [(python3.withPackages (python-pkgs: [ python-pkgs.websockets ]))];
cmakeFlags = [ "-DUSE_PLASMAPKG=OFF" ];
dontWrapQtApps = true;
postPatch = ''
rm -rf src/backend_scene/third_party/glslang
ln -s ${glslang-submodule.src} src/backend_scene/third_party/glslang
'';
#Optional informations
meta = with lib; {
description = "Wallpaper Engine KDE plasma plugin";
homepage = "https://github.com/Jelgnum/wallpaper-engine-kde-plugin";
license = licenses.gpl2Plus;
platforms = platforms.linux;
};
};
in
{
options.nixos = {
pkgs.wallpaper-engine-kde-plugin = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Enable wallpaper-engine-kde-plugin.";
};
};
};
config = lib.mkIf (config.nixos.pkgs.wallpaper-engine-kde-plugin.enable) {
environment.systemPackages = with pkgs; [
wallpaper-engine-kde-plugin
kdePackages.qtwebsockets
kdePackages.qtwebchannel
(python3.withPackages (python-pkgs: [ python-pkgs.websockets ]))
];
system.activationScripts = {
wallpaper-engine-kde-plugin.text = ''
wallpaperenginetarget=/share/plasma/wallpapers/com.github.catsout.wallpaperEngineKde
mkdir -p /home/${builtins.head (builtins.attrNames config.users.users)}/.local/share/plasma/wallpapers
chown -R ${builtins.head (builtins.attrNames config.users.users)}:users /home/${builtins.head (builtins.attrNames config.users.users)}/.local/share/plasma
if [ ! -e /home/${builtins.head (builtins.attrNames config.users.users)}/.local$wallpaperenginetarget ]; then
ln -sf ${wallpaper-engine-kde-plugin}$wallpaperenginetarget /home/${builtins.head (builtins.attrNames config.users.users)}/.local$wallpaperenginetarget
fi;
'';
};
};
}
@BBArikL
Copy link
Author

BBArikL commented Jan 11, 2025

A few notes:

  • To enable it, import it into your preferred nix config file and enable it as so:
imports = [
    ./wallpaper-engine-kde-plugin.nix  # Or another path to the file
];
....
nixos.pkgs = {
    wallpaper-engine-kde-plugin.enable = true;
  };
  • It is definitely not the latest git version of the code but I am thinking of using nvfetcher to automate it.
  • Doing the symbolic link does not seem to work for me as it is doing a symlink of another symlink and plasma does not seem to like it. After installing, you have to go to $HOME/.local/share/plasma/wallpapers/, follow the symlink, copy the targeted symlink and copy it back into $HOME/.local/share/plasma/wallpapers/.
  • I added qtwebchannel as a runtime dependency for support for web scenes, but interaction with the web frame does not seem to work (I think it is not yet implemented in the actual plugin so it should not be a problem with the packaging).
  • This script was derived from @xerhaxs own package where the user is configured with config.nixos.system.user.defaultuser.name. I could not find a generic way to do it if your configuration is not using that specific name, so I relied on the logname utility to find the user. Now, this means this package needs to be activated while the target user is logged in (or it might assume the root, but it still works if you run the nixos-rebuild as root). For most people I do not think this is too much too ask, but it might be a flaw for people who would want a perfect one config installation.
  • I am open to improvements so it is possible for future users to install it directly from the nix store.

@ayamir
Copy link

ayamir commented Feb 23, 2025

Hello, thanks for your great work! I have installed it successfully by following your config, but I encountered this problem, could you please help me debug it or give me some debug threads?
image

@ayamir
Copy link

ayamir commented Feb 23, 2025

@BBArikL
Copy link
Author

BBArikL commented Feb 24, 2025

yea my config is a little bit out of date. Its missing some python dependencies at line 58. I am mostly thinking of automating it in about a week for it to be accessible from the nixpkg store.

@BBArikL
Copy link
Author

BBArikL commented Mar 3, 2025

About the python error: I think this is mostly waiting for a plasma reboot because after another round of testing I do not have the python helper problem.

@shantanuprasadbtech
Copy link

I'm also having the same error, I tried restarting twice but no change.

@BBArikL
Copy link
Author

BBArikL commented Mar 24, 2025

If you are on Nixos unstable , you might want to use the actual merged package NixOS/nixpkgs#334984. Even if NixOS is so pointed to reproducible builds with configs, sometimes it seems like stuff don't actually work the same. If you don't have python on your system, this might be a problem? Just guessing

@BBArikL
Copy link
Author

BBArikL commented Mar 24, 2025

The nixos package does patch the pyext.py script, that might be the problem that I do not tackle here.

@shantanuprasadbtech
Copy link

shantanuprasadbtech commented Apr 5, 2025

So I solved the issue, though honestly I'm not sure why it works. I searched up my issue online, and found this post. But since I'm still a completely beginner to nix and nixos, I didn't know how to run the script it gives.

So I decided to follow the script manually. I found out the exact nix store path, and manually created a symlink between the two:
ln -sf /nix/store/g55hivkdl0vr5w7mw7d5cq41cl5nkm3r-wallpaperEngineKde-96230de92f1715d3ccc5b9d50906e6a73812a00a/share/plasma/wallpapers/com.github.catsout.wallpaperEngineKde/ ~/.local/share/plasma/wallpapers/com.github.catsout.wallpaperEngineKde

Restarted my system, and lo and behold, somehow now it works perfectly. I don't know if the store path would be the same for all systems, but for anyone with the same problem, the solution seems to be just manually create a symlink from ~/.local/share/plasma/wallpapers/, pointing to the com.github.catsout.wallpaperEngineKde folder in the nix store path.

Probably not the best or most "Nix" solution, but it works.

@BBArikL, if I'm not mistaken, the very last line of your script should be doing the same thing, but somehow it doesn't seem to be working? Maybe the file path is wrong, or the if statement is messing something up?

@BBArikL
Copy link
Author

BBArikL commented Apr 5, 2025

Hey! Yes the store path is different between each system and each nix generation (its basically a hash that is derived from your system configuration). Before, I was not using a leading / for the wallpaper engine target, but I was corrected by people in that discourse thread to add that leading forward slash. I think I have an inconsistent usage of the $wallpaperenginetarget. I'll make a new revision but I cannot test it right now. For people on nixos unstable, I'd recommend to go for the one in the official (nix) repo. If it ever comes on nixos stable, I will stop maintaining this gist and use the one which is in the nix repo.

@qwbarch
Copy link

qwbarch commented Apr 11, 2025

Thanks for making this package!

OK, this error disappeared after use this config: https://github.com/xerhaxs/nixos/blob/main/nixosModules/pkgs/wallpaper-engine-kde-plugin.nix

I indeed needed this as well to make python run properly. Seems like video wallpapers run (after installing qtmultimediate) while all scene wallpapers have a black screen. Is that an issue with the packaging or the plugin itself? wallpaper-engine-kde-plugin seems to support scene wallpapers so I'm not sure if I'm just doing something wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment