Wallpaper: Refactor a bit.

This commit is contained in:
Dmitry Voronin 2025-01-02 06:43:46 +03:00
parent f5e877b668
commit f5e9976641
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
2 changed files with 7 additions and 6 deletions
host/x86_64-linux/home
option

View file

@ -194,7 +194,7 @@ in
# Public SSH access. # Public SSH access.
# ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 22143 # ip46tables -I INPUT -j ACCEPT -i ${wan} -p tcp --dport 22143
''; '';
}; };
}; };
} }

View file

@ -22,14 +22,15 @@ let
scheme = null; scheme = null;
# Extract image from video. # Extract image from video.
videoImage = videoPath = if video then pkgs.fetchurl { inherit url sha256; } else null;
image =
if video then if video then
pkgs.runCommandNoCC "wallpaper-video-image" { } '' pkgs.runCommandNoCC "wallpaper-video-image" { } ''
${pkgs.ffmpeg}/bin/ffmpeg -hide_banner -loglevel error -ss 00:00:00 -i ${cfg.videoPath} -frames:v 1 -q:v 1 Image.jpg ${pkgs.ffmpeg}/bin/ffmpeg -hide_banner -loglevel error -ss 00:00:00 -i ${videoPath} -frames:v 1 -q:v 1 Image.jpg
cp Image.jpg $out cp Image.jpg $out
'' ''
else else
null; pkgs.fetchurl { inherit url sha256; };
in in
{ {
options.module.wallpaper = { options.module.wallpaper = {
@ -38,7 +39,7 @@ in
type = lib.types.bool; type = lib.types.bool;
}; };
path = lib.mkOption { path = lib.mkOption {
default = if video then videoImage else pkgs.fetchurl { inherit url sha256; }; default = image;
type = lib.types.path; type = lib.types.path;
}; };
video = lib.mkOption { video = lib.mkOption {
@ -46,7 +47,7 @@ in
type = lib.types.bool; type = lib.types.bool;
}; };
videoPath = lib.mkOption { videoPath = lib.mkOption {
default = if video then pkgs.fetchurl { inherit url sha256; } else null; default = videoPath;
type = with lib.types; nullOr path; type = with lib.types; nullOr path;
}; };
scheme = lib.mkOption { scheme = lib.mkOption {