Files
Nomarchy/themes/engine/files.nix
Bernardo Magri 431dd98967
All checks were successful
Check / eval-and-lint (push) Successful in 6m58s
feat(theme): implement declarative Stylix-driven theming for Walker
2026-06-01 21:09:54 +01:00

174 lines
6.3 KiB
Nix

{ config, lib, ... }:
let
nomarchyLib = import ../../lib { inherit lib; };
themePath = ../palettes + "/${config.nomarchy.theme}";
themeAppsPath = themePath + "/apps";
nordAppsPath = ../../features/desktop/hyprland/themes/nord;
hyprlandThemePath = ../../features/desktop/hyprland/themes + "/${config.nomarchy.theme}";
# Check if theme has hyprland.conf in palette apps/ or feature themes/
hasHyprlandConf = builtins.pathExists (themeAppsPath + "/hyprland.conf");
hasHyprlandFeatureConf = builtins.pathExists (hyprlandThemePath + "/hyprland.conf");
hyprlandConfSource =
if hasHyprlandConf then themeAppsPath + "/hyprland.conf"
else if hasHyprlandFeatureConf then hyprlandThemePath + "/hyprland.conf"
else nordAppsPath + "/hyprland.conf";
# Get palette for dynamic CSS generation
palette = nomarchyLib.getPalette config.nomarchy.theme;
in
{
xdg.configFile."nomarchy/current/theme" = {
source = themePath;
recursive = true;
};
# Generate waybar.css if it doesn't exist in the theme
# This provides the @background and @foreground variables used by the default style
xdg.configFile."nomarchy/current/theme/waybar.css".text = ''
@define-color background #${palette.base00};
@define-color foreground #${palette.base05};
@define-color accent #${palette.base0D};
'';
# Per-palette kitty colors. features/apps/kitty/config/kitty.conf includes
# this file; without it the include silently failed and kitty stayed on
# default colors for every palette (Stylix's kitty target only kicks in
# when programs.kitty.enable is set, which the module doesn't use).
xdg.configFile."nomarchy/current/theme/kitty.conf".text = ''
background #${palette.base00}
foreground #${palette.base05}
cursor #${palette.base05}
selection_background #${palette.base02}
selection_foreground #${palette.base05}
color0 #${palette.base01}
color1 #${palette.base08}
color2 #${palette.base0B}
color3 #${palette.base0A}
color4 #${palette.base0D}
color5 #${palette.base0E}
color6 #${palette.base0C}
color7 #${palette.base04}
color8 #${palette.base03}
color9 #${palette.base08}
color10 #${palette.base0B}
color11 #${palette.base0A}
color12 #${palette.base0D}
color13 #${palette.base0E}
color14 #${palette.base0C}
color15 #${palette.base07}
'';
# Per-palette ghostty colors. features/apps/ghostty/config/config uses an
# optional include (?-prefix) of this file; without it the include was
# silently skipped and ghostty rendered with its built-in defaults across
# every palette. ghostty has no Stylix target.
xdg.configFile."nomarchy/current/theme/ghostty.conf".text = ''
background = ${palette.base00}
foreground = ${palette.base05}
cursor-color = ${palette.base05}
selection-background = ${palette.base02}
selection-foreground = ${palette.base05}
palette = 0=#${palette.base01}
palette = 1=#${palette.base08}
palette = 2=#${palette.base0B}
palette = 3=#${palette.base0A}
palette = 4=#${palette.base0D}
palette = 5=#${palette.base0E}
palette = 6=#${palette.base0C}
palette = 7=#${palette.base04}
palette = 8=#${palette.base03}
palette = 9=#${palette.base08}
palette = 10=#${palette.base0B}
palette = 11=#${palette.base0A}
palette = 12=#${palette.base0D}
palette = 13=#${palette.base0E}
palette = 14=#${palette.base0C}
palette = 15=#${palette.base07}
'';
# Ensure theme-specific hyprland config exists
# Lookup priority: palette apps/ > feature themes/ > nord fallback
xdg.configFile."nomarchy/current/theme/apps/hyprland.conf" = lib.mkIf (!hasHyprlandConf) {
source = if hasHyprlandFeatureConf then hyprlandThemePath + "/hyprland.conf"
else nordAppsPath + "/hyprland.conf";
};
# Legacy compatibility: symlink apps/hyprland.conf to root for scripts expecting old path
xdg.configFile."nomarchy/current/theme/hyprland.conf" = {
source = hyprlandConfSource;
};
# Rofi fallback support
xdg.configFile."rofi/config.rasi" = lib.mkIf (builtins.pathExists (themeAppsPath + "/rofi.rasi")) {
source = themeAppsPath + "/rofi.rasi";
};
# Dynamically generated CSS for Walker app launcher
xdg.configFile."nomarchy/current/theme/apps/walker/style.css".text = ''
#window {
background-color: #${palette.base00};
color: #${palette.base05};
border-bottom: 5px solid #${palette.base0D}; /* Accent */
border-radius: 15px;
}
#search {
background-color: #${palette.base01};
color: #${palette.base05};
border-bottom: 5px solid #${palette.base02};
border-radius: 10px;
margin: 15px;
padding: 10px;
}
#input {
color: #${palette.base05};
}
#list {
padding: 20px;
}
.item {
border-radius: 10px;
padding: 10px;
color: #${palette.base05};
}
.item.active {
background-color: #${palette.base02};
color: #${palette.base05};
border-bottom: 5px solid #${palette.base0D}; /* Accent */
}
'';
xdg.configFile."nomarchy/current/theme.name".text = config.nomarchy.theme;
# Expose branding assets
xdg.configFile."nomarchy/branding/logo.png".source = ../../core/branding/logo.png;
xdg.configFile."nomarchy/branding/logo.txt".source = ../../core/branding/logo.txt;
xdg.configFile."nomarchy/branding/logo.svg".source = ../../core/branding/logo.svg;
xdg.configFile."nomarchy/branding/icon.png".source = ../../core/branding/icon.png;
xdg.configFile."nomarchy/branding/icon.txt".source = ../../core/branding/icon.txt;
xdg.configFile."nomarchy/branding/screensaver.txt".source = ../../core/branding/screensaver.txt;
xdg.configFile."nomarchy/branding/about.txt".source = ../../core/branding/about.txt;
# Expose all themes to the system via local share for script accessibility
xdg.dataFile."nomarchy/themes".source = builtins.path {
name = "nomarchy-themes";
path = ../palettes;
};
# Expose all theme templates to the system via local share
xdg.dataFile."nomarchy/templates".source = builtins.path {
name = "nomarchy-templates";
path = ../templates;
};
# Nautilus python extensions
xdg.dataFile."nautilus-python/extensions/localsend.py".source = ../../core/home/config/nautilus-python/extensions/localsend.py;
}