blender: use mkTarget (#1509)

Link: https://github.com/nix-community/stylix/pull/1509

Reviewed-by: awwpotato <awwpotato@voidq.com>
Tested-by: Louis Dalibard <louis.dalibard@gmail.com>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
Flameopathic 2025-07-01 16:13:57 +02:00 committed by GitHub
parent 73b7d0f300
commit 4bc15ef13c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1582 additions and 1567 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,40 @@
{ fonts }:
{
stylix.targets.blender.themeBody = ''
<ThemeStyle>
<panel_title>
<ThemeFontStyle
points="${toString fonts.sizes.desktop}"
character_weight="400"
shadow="1"
shadow_offset_x="0"
shadow_offset_y="-1"
shadow_alpha="0.15"
shadow_value="1"
></ThemeFontStyle>
</panel_title>
<widget_label>
<ThemeFontStyle
points="${toString fonts.sizes.popups}"
character_weight="400"
shadow="3"
shadow_offset_x="0"
shadow_offset_y="-1"
shadow_alpha="0.15"
shadow_value="1"
></ThemeFontStyle>
</widget_label>
<widget>
<ThemeFontStyle
points="${toString fonts.sizes.popups}"
character_weight="400"
shadow="0"
shadow_offset_x="0"
shadow_offset_y="0"
shadow_alpha="0.25"
shadow_value="0"
></ThemeFontStyle>
</widget>
</ThemeStyle>
'';
}

View file

@ -1,46 +1,52 @@
{
config,
mkTarget,
lib,
pkgs,
...
}:
{
options.stylix.targets.blender.enable =
config.lib.stylix.mkEnableTarget "blender" true;
mkTarget {
name = "blender";
humanName = "Blender";
config =
lib.mkIf (config.stylix.enable && config.stylix.targets.blender.enable)
extraOptions.themeBody = lib.mkOption {
type = lib.types.lines;
default = "";
internal = true;
};
configElements = [
./color-theme.nix
./font-theme.nix
(
{ cfg }:
{
xdg.configFile =
let
theme = pkgs.writeText "Stylix.replaced.xml.mustache" (
builtins.replaceStrings
[ "%POPUPSFONTSIZE%" "%DESKTOPFONTSIZE%" ]
[
(toString config.stylix.fonts.sizes.popups)
(toString config.stylix.fonts.sizes.desktop)
]
(builtins.readFile ./Stylix.xml.mustache)
);
indent =
string: " " + lib.concatStringsSep "\n " (lib.splitString "\n" string);
in
builtins.listToAttrs (
map
(
version:
lib.nameValuePair
"blender/${version}/scripts/presets/interface_theme/Stylix.xml"
{
source = config.lib.stylix.colors {
template = theme;
extension = ".xml";
};
}
)
[
"4.2"
"4.3"
"4.4"
]
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>"
];
}
)
[
"4.2"
"4.3"
"4.4"
]
)
);
};
}
)
];
}