From 29f64105bca9f528d2b9812cb7d490a27c6a2633 Mon Sep 17 00:00:00 2001 From: aristote Date: Mon, 18 Dec 2023 17:04:26 +0100 Subject: pkgs: wallpapers: change options --- pkgs/static/wallpapers/default.nix | 54 ++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'pkgs/static/wallpapers/default.nix') diff --git a/pkgs/static/wallpapers/default.nix b/pkgs/static/wallpapers/default.nix index f0b8d46..a0efda3 100644 --- a/pkgs/static/wallpapers/default.nix +++ b/pkgs/static/wallpapers/default.nix @@ -1,22 +1,36 @@ -{ stdenv, fetchurl, imagemagick, lib }: - -let +{ + stdenv, + fetchurl, + imagemagick, + lib, +}: let fetchWallpaper = lib.makeOverridable ( - { name, url, sha256, resolution ? "1920x1080", offset ? "0x0" }: - stdenv.mkDerivation { - inherit name; - src = fetchurl { - inherit url sha256; - }; - buildInputs = [ imagemagick ]; - phases = [ "unpackPhase" ]; - unpackPhase = '' - convert "$src" -resize "${resolution}^" \ - -crop "${resolution}+${offset}" \ - "$out" - ''; - }); + { + name, + url, + sha256, + resolution ? "1920x1080", + ratio ? "16:9", + gravity ? "center", + }: + stdenv.mkDerivation { + inherit name; + src = fetchurl { + inherit url sha256; + }; + buildInputs = [imagemagick]; + phases = ["unpackPhase"]; + unpackPhase = '' + convert "$src" -gravity '${gravity}' \ + -extent '${ratio}' \ + -resize '${resolution}!' \ + "$out" + ''; + } + ); sources = lib.importJSON ./sources.json; -in { - fetcher = fetchWallpaper; -} // builtins.mapAttrs (_: fetchWallpaper) sources +in + { + fetcher = fetchWallpaper; + } + // builtins.mapAttrs (_: fetchWallpaper) sources -- cgit v1.2.3