nix-git/modules/wallpaper.nix

21 lines
797 B
Nix
Raw Permalink Normal View History

2024-09-04 22:13:38 +02:00
{ pkgs, lib }:
let
2024-09-24 16:17:52 +02:00
# TODO use formula: 1920×16÷9÷3×2
2024-09-04 22:13:38 +02:00
# Width of our display.
2024-09-24 16:17:52 +02:00
max-width = "2276";
2024-09-04 22:13:38 +02:00
in
pkgs.stdenv.mkDerivation rec{
name = "yoda-wallpaper";
src = "${../assets/img/wallpaper.jpg}";
nativeBuildInputs = with pkgs; [ imagemagick ];
phases = "installPhase";
# magick limit width: https://stackoverflow.com/a/38415211/6334421
# magick jpg options: quality, progressive, strip metadata. https://stackoverflow.com/a/7262050/6334421
installPhase = ''
set -eu -o pipefail
mkdir -p $out
2024-09-22 14:03:36 +02:00
${pkgs.imagemagick}/bin/magick $src -resize '${max-width}>' -quality 90% -interlace Plane -strip $out/img.jpg
2024-09-04 22:13:38 +02:00
${pkgs.imagemagick}/bin/magick $src -resize '${max-width}>' $out/img.png
'';
}