{pkgs}: {
  palette,
  wallpaper,
}: let
  str_pal = with pkgs.lib; concatStringsSep " " (builtins.foldl' (acc: el: acc ++ (attrValues el)) [] [palette.normal palette.bright palette.util]);
in
  pkgs.stdenv.mkDerivation rec {
    name = "generated-wallpaper.png";
    src = wallpaper;
    buildInputs = [
      pkgs.lutgen
    ];

    phases = ["installPhase"];

    installPhase = ''
      echo -e "Generating wallpaper from ${wallpaper} using palette:\n${str_pal}.."
      ${pkgs.lib.getExe pkgs.lutgen} apply --lum 0.8 -l 10 -s 128 -n 8 -o $out ${wallpaper} -- ${str_pal}
    '';
  }
