mirror of
https://codeberg.org/privacy1st/nix-git
synced 2024-11-21 22:03:19 +01:00
smaller wallpaper size
This commit is contained in:
parent
ffb28bb11a
commit
747ec77850
@ -11,6 +11,6 @@
|
|||||||
"picture-uri-dark" = "/home/yoda/.config/background";
|
"picture-uri-dark" = "/home/yoda/.config/background";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
home.file.".config/background".source = "${../assets/img/wallpaper.jpg}";
|
home.file.".config/background".source = "${(pkgs.callPackage ./wallpaper.nix { })}/img.jpg";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
22
modules/wallpaper-test.nix
Normal file
22
modules/wallpaper-test.nix
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# To inspect ./wallpaper.nix, adjust the `expr` of the two tests below and then run the following command:
|
||||||
|
# nix --extra-experimental-features nix-command eval --show-trace --impure --expr 'import ./modules/wallpaper-test.nix {}'
|
||||||
|
#
|
||||||
|
# Source: https://www.tweag.io/blog/2022-09-01-unit-test-your-nix-code/
|
||||||
|
|
||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
let
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
inherit (lib) runTests;
|
||||||
|
math = import ./wallpaper.nix {inherit lib pkgs;};
|
||||||
|
in
|
||||||
|
runTests {
|
||||||
|
test1 = {
|
||||||
|
expr = pkgs.lib.attrNames math;
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
test2 = {
|
||||||
|
expr = "${math.out}/img.jpg";
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
}
|
19
modules/wallpaper.nix
Normal file
19
modules/wallpaper.nix
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{ pkgs, lib }:
|
||||||
|
let
|
||||||
|
# Width of our display.
|
||||||
|
max-width = "1080";
|
||||||
|
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
|
||||||
|
${pkgs.imagemagick}/bin/magick $src -resize '${max-width}>' -quality 85% -interlace Plane -strip $out/img.jpg
|
||||||
|
${pkgs.imagemagick}/bin/magick $src -resize '${max-width}>' $out/img.png
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user