summaryrefslogtreecommitdiff
path: root/pkgs/static/wallpapers/default.nix
diff options
context:
space:
mode:
authorquentin@aristote.fr <quentin@aristote.fr>2023-12-20 13:33:35 +0100
committerquentin@aristote.fr <quentin@aristote.fr>2023-12-20 13:33:35 +0100
commitc89edb0b37c6343d32c146547dfb54fcdb69b158 (patch)
treef810c4f730d391fc6a40dfc807fb1b6a302dcf99 /pkgs/static/wallpapers/default.nix
parentc62c1c07b9acaebc4d51d8464d35fd0c3b0dfc20 (diff)
parent29f64105bca9f528d2b9812cb7d490a27c6a2633 (diff)
Merge branch 'master' into devenv
Diffstat (limited to 'pkgs/static/wallpapers/default.nix')
-rw-r--r--pkgs/static/wallpapers/default.nix54
1 files changed, 34 insertions, 20 deletions
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