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
55 lines
1.3 KiB
Nix
55 lines
1.3 KiB
Nix
{ mkTarget, lib, ... }:
|
|
mkTarget {
|
|
options.themeBody = lib.mkOption {
|
|
type = lib.types.lines;
|
|
default = "";
|
|
internal = true;
|
|
};
|
|
|
|
config = [
|
|
./color-theme.nix
|
|
./font-theme.nix
|
|
(
|
|
{ cfg }:
|
|
{
|
|
xdg.configFile =
|
|
let
|
|
indent =
|
|
string: " " + lib.concatStringsSep "\n " (lib.splitString "\n" string);
|
|
in
|
|
lib.mkIf (cfg.themeBody != "") (
|
|
builtins.listToAttrs (
|
|
map
|
|
(
|
|
version:
|
|
lib.nameValuePair
|
|
"blender/${version}/scripts/presets/interface_theme/Stylix.xml"
|
|
{
|
|
text = lib.concatLines [
|
|
"<bpy>"
|
|
(indent cfg.themeBody)
|
|
"</bpy>"
|
|
];
|
|
}
|
|
)
|
|
[
|
|
"3.0"
|
|
"3.1"
|
|
"3.2"
|
|
"3.3"
|
|
"3.4"
|
|
"3.5"
|
|
"3.6"
|
|
"4.0"
|
|
"4.1"
|
|
"4.2"
|
|
"4.3"
|
|
"4.4"
|
|
"4.5"
|
|
]
|
|
)
|
|
);
|
|
}
|
|
)
|
|
];
|
|
}
|