Optionalize mkTarget's 'humanName' and 'name' arguments by inferring
'humanName' from the 'name' attribute in the /modules/<MODULE>/meta.nix
file, and 'name' from the /modules/<NAME>/ directory name.
Inferring the 'humanName' and 'name' arguments ensures consistency and
reduces boilerplate.
The 'humanName' and 'name' arguments are optionalized instead of removed
because complex modules generating target derivations need to
distinguish between them.
Closes: https://github.com/nix-community/stylix/issues/1661
(cherry picked from commit dfc859f54d)
30 lines
792 B
Nix
30 lines
792 B
Nix
{ mkTarget, lib, ... }:
|
|
mkTarget {
|
|
config =
|
|
{ imageScalingMode, image }:
|
|
(
|
|
let
|
|
# wpaperd doesn't have any mode close to the described behavior of center
|
|
modeMap = {
|
|
"stretch" = "stretch";
|
|
# wpaperd's center mode is closest to the described behavior of fill
|
|
"fill" = "center";
|
|
"fit" = "fit";
|
|
"tile" = "tile";
|
|
};
|
|
|
|
modeAttrs =
|
|
if builtins.hasAttr imageScalingMode modeMap then
|
|
{ mode = modeMap.${imageScalingMode}; }
|
|
else
|
|
lib.info "stylix: wpaperd: unsupported image scaling mode: ${imageScalingMode}"
|
|
{ };
|
|
in
|
|
{
|
|
services.wpaperd.settings.any = {
|
|
path = image;
|
|
}
|
|
// modeAttrs;
|
|
}
|
|
);
|
|
}
|