Files
Nomarchy/modules/home/theme-loader.nix
Bernardo Magri b27fc5aee8 refactor: major architectural restructure for theme-centric organization
Theme System:
- Move all theme app configs to apps/ subdirectory (20 themes)
- Add theme-loader.nix for dynamic theme config deployment
- Simplify stylix.nix to focus on base theming only

Override System:
- Add overrides.nix for file-based config overrides
- Add behavior-configs.nix for non-visual configuration
- Split hypr/nomarchy.conf into behavior vs visual sections

Module Improvements:
- Add lib.mkDefault to all customizable settings
- Add modules/lib/ with shared utilities and state schema
- Update all home and system modules for downstream overridability

Installer:
- New minimal TTY installer (installer/install.sh)
- Golden path: BTRFS + LUKS2 (disko-golden.nix)
- New installer-iso.nix for TTY-only installation
- Keep graphical installer as installerIsoGraphical option

Cleanup:
- Remove obsolete install.sh, disko-ext4.nix, install-nomarchy.sh
- Update live-iso.nix references
- Add .claude/ to .gitignore for local IDE settings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-11 19:38:27 +01:00

129 lines
4.4 KiB
Nix

{ config, lib, pkgs, ... }:
# Theme Loader Module
#
# This module handles loading and deploying theme-specific application configs.
# It reads the active theme from state and deploys configs from the theme's apps/
# subdirectory to appropriate locations.
#
# Theme structure expected:
# assets/themes/<theme-name>/
# ├── colors.toml # Color palette (required)
# ├── light.mode # Marker for light themes (optional)
# ├── icons.theme # Icon theme name
# ├── backgrounds/ # Wallpapers
# ├── apps/ # App-specific themed configs
# │ ├── alacritty.toml
# │ ├── kitty.conf
# │ ├── waybar.css
# │ ├── hyprland-colors.conf
# │ ├── mako.conf
# │ ├── swayosd.css
# │ ├── btop.theme
# │ ├── vscode.json
# │ └── neovim.lua
# └── preview.png
let
nomarchyLib = import ../lib { inherit lib; };
assetsPath = ../../assets/themes;
activeTheme = config.nomarchy.theme;
themePath = assetsPath + "/${activeTheme}";
themeAppsPath = themePath + "/apps";
# Check if a theme has an apps directory
themeHasApps = builtins.pathExists themeAppsPath;
# Get the color palette for template processing
palette = nomarchyLib.getPalette activeTheme;
# Helper to check if a file exists in theme
hasThemeFile = name: builtins.pathExists (themePath + "/${name}");
hasThemeAppFile = name: themeHasApps && builtins.pathExists (themeAppsPath + "/${name}");
# All app configs are now in apps/ subdirectory
# Legacy root-level files are no longer supported
in
{
options.nomarchy.themeLoader = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to enable automatic theme app config loading.";
};
apps = {
btop = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to load btop theme from active theme.";
};
waybar = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to load waybar CSS from active theme.";
};
mako = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to load mako config from active theme.";
};
kitty = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to load kitty config from active theme.";
};
alacritty = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to load alacritty config from active theme.";
};
};
};
config = lib.mkIf config.nomarchy.themeLoader.enable {
# Deploy btop theme if available in apps/
xdg.configFile."btop/themes/nomarchy.theme" = lib.mkIf (config.nomarchy.themeLoader.apps.btop && hasThemeAppFile "btop.theme") {
source = lib.mkDefault (themeAppsPath + "/btop.theme");
};
# Note: Waybar CSS is generated inline in waybar.nix using colorScheme
# This loader would be used if themes provide complete waybar.css overrides
# For now, theme waybar.css files are only used for themes that need
# significantly different styling (like retro-82)
# Create theme info file for scripts
xdg.configFile."nomarchy/theme-loader/current".text = ''
THEME_NAME="${activeTheme}"
THEME_PATH="${toString themePath}"
THEME_HAS_APPS="${if themeHasApps then "true" else "false"}"
IS_LIGHT_MODE="${if config.nomarchy.isLightMode then "true" else "false"}"
ICONS_THEME="${config.nomarchy.iconsTheme}"
'';
# Expose palette as shell-sourceable file for scripts
xdg.configFile."nomarchy/theme-loader/palette.sh".text = ''
# Auto-generated palette for ${activeTheme}
# Source this file in scripts to get theme colors
BASE00="${palette.base00}"
BASE01="${palette.base01}"
BASE02="${palette.base02}"
BASE03="${palette.base03}"
BASE04="${palette.base04}"
BASE05="${palette.base05}"
BASE06="${palette.base06}"
BASE07="${palette.base07}"
BASE08="${palette.base08}"
BASE09="${palette.base09}"
BASE0A="${palette.base0A}"
BASE0B="${palette.base0B}"
BASE0C="${palette.base0C}"
BASE0D="${palette.base0D}"
BASE0E="${palette.base0E}"
BASE0F="${palette.base0F}"
'';
};
}