linux-wallpaperengine: fix evaluation error when passing null (#7161)

This commit is contained in:
ckgxrg 2025-05-30 23:26:35 +08:00 committed by GitHub
parent d800d198b8
commit 214f9bd3a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 4 deletions

View file

@ -19,7 +19,8 @@ in
package = lib.mkPackageOption pkgs "linux-wallpaperengine" { };
assetsPath = mkOption {
type = types.path;
type = types.nullOr types.path;
default = null;
description = "Path to the assets directory.";
};
@ -104,6 +105,10 @@ in
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.linux-wallpaperengine" pkgs lib.platforms.linux)
({
assertion = cfg.wallpapers != null;
message = "linux-wallpaperengine: You must set at least one wallpaper";
})
];
home.packages = [ cfg.package ];
@ -135,8 +140,8 @@ in
Service = {
ExecStart =
lib.getExe cfg.package
+ " --assets-dir ${cfg.assetsPath} "
+ "--clamping ${cfg.clamping} "
+ (lib.optionalString (cfg.assetsPath != null) " --assets-dir ${cfg.assetsPath} ")
+ (lib.optionalString (cfg.clamping != null) "--clamping ${cfg.clamping} ")
+ (lib.strings.concatStringsSep " " args);
Restart = "on-failure";
};

View file

@ -1 +1,4 @@
{ linux-wallpaperengine-basic-configuration = ./basic-configuration.nix; }
{
linux-wallpaperengine-basic-configuration = ./basic-configuration.nix;
linux-wallpaperengine-null-options = ./null-options.nix;
}

View file

@ -0,0 +1,11 @@
[Install]
WantedBy=graphical-session.target
[Service]
ExecStart=@linux-wallpaperengine@/bin/linux-wallpaperengine
Restart=on-failure
[Unit]
After=graphical-session.target
Description=Implementation of Wallpaper Engine on Linux
PartOf=graphical-session.target

View file

@ -0,0 +1,11 @@
{
services.linux-wallpaperengine = {
enable = true;
};
nmt.script = ''
assertFileContent \
home-files/.config/systemd/user/linux-wallpaperengine.service \
${./null-options-expected.service}
'';
}