stylix: feed stylix base16 colours into the zen and vesktop CSS templates

Neither app has a native stylix target, but their existing matugen
templates are just CSS with Material You placeholders. Read the
templates at Nix-eval time and substitute the placeholders with the
closest stylix.colors.base0X slot (primary=base0D, surface=base00,
on_surface=base05, etc.). Same outcome as the old matugen post-hook,
just sourced from stylix.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
ediblerope 2026-05-11 20:08:36 +01:00
parent 8ea4e666cc
commit f55c0b9df6

View file

@ -34,7 +34,51 @@
}; };
}; };
home-manager.users.fred = { config, lib, pkgs, ... }: { home-manager.users.fred = { config, lib, pkgs, ... }: let
c = config.lib.stylix.colors;
# Map matugen's Material You placeholders to the closest base16 slot
# in stylix's palette. The mapping is approximate (Material You has
# more semantic colours than base16), but covers the placeholders
# used in our Zen userChrome and Vesktop quickCss templates.
stylixize = builtins.replaceStrings
[
"{{colors.primary.default.hex}}"
"{{colors.primary_container.default.hex}}"
"{{colors.secondary_container.default.hex}}"
"{{colors.tertiary_container.default.hex}}"
"{{colors.surface.default.hex}}"
"{{colors.surface_container.default.hex}}"
"{{colors.surface_container_low.default.hex}}"
"{{colors.surface_container_high.default.hex}}"
"{{colors.on_surface.default.hex}}"
"{{colors.on_surface_variant.default.hex}}"
"{{colors.outline.default.hex}}"
"{{colors.outline_variant.default.hex}}"
]
[
"#${c.base0D}" # primary accent
"#${c.base02}" # primary container
"#${c.base0C}" # secondary container (cyan)
"#${c.base0E}" # tertiary container (purple)
"#${c.base00}" # surface (main bg)
"#${c.base01}" # surface container
"#${c.base00}" # surface container low
"#${c.base02}" # surface container high
"#${c.base05}" # on surface (fg)
"#${c.base04}" # on surface variant (muted fg)
"#${c.base03}" # outline
"#${c.base02}" # outline variant
];
in {
# Zen and Vesktop have no native stylix targets, so we keep the
# existing matugen CSS templates and substitute placeholders with
# stylix base16 colours at Nix-eval time.
home.file.".zen/fraudek5.Default Profile/chrome/userChrome.css".text =
stylixize (builtins.readFile "${inputs.self}/templates/zen-userChrome.css");
home.file.".config/vesktop/settings/quickCss.css".text =
stylixize (builtins.readFile "${inputs.self}/templates/vesktop-quickCss.css");
# Folder icon recolor — was a matugen post-hook, now driven by # Folder icon recolor — was a matugen post-hook, now driven by
# stylix's base16 palette. base0D is the conventional blue/accent # stylix's base16 palette. base0D is the conventional blue/accent
# slot, which is what we want for Adwaita-style folder icons. # slot, which is what we want for Adwaita-style folder icons.