{ user ? throw "user argument is required" }: { config, lib, pkgs, ... }: let hmConfig = config.home-manager.users."${user.name}"; in { home-manager.users."${user.name}" = { programs.matugen = { enable = true; settings = { config = { custom_colors = let mkColor = category: color: { color = hmConfig.theme.color.${category}.${color}; blend = hmConfig.theme.color.${category}.blend; }; in { danger = mkColor "semantic" "danger"; warning = mkColor "semantic" "warning"; success = mkColor "semantic" "success"; info = mkColor "semantic" "info"; red = mkColor "ansi" "red"; green = mkColor "ansi" "green"; yellow = mkColor "ansi" "yellow"; orange = mkColor "ansi" "orange"; blue = mkColor "ansi" "blue"; magenta = mkColor "ansi" "magenta"; cyan = mkColor "ansi" "cyan"; keywords = mkColor "syntax" "keywords"; functions = mkColor "syntax" "functions"; properties = mkColor "syntax" "properties"; constants = mkColor "syntax" "constants"; strings = mkColor "syntax" "strings"; numbers = mkColor "syntax" "numbers"; structures = mkColor "syntax" "structures"; types = mkColor "syntax" "types"; }; custom_keywords = { flavour = hmConfig.theme.flavour; contrast = builtins.toString hmConfig.theme.contrast; opacity = builtins.toString hmConfig.theme.opacity; transparency = builtins.toString (1 - hmConfig.theme.opacity); radius = builtins.toString hmConfig.theme.radius; padding = builtins.toString hmConfig.theme.padding; double_padding = builtins.toString (hmConfig.theme.padding * 2); blur = builtins.toString hmConfig.theme.blur; }; }; templates = { }; }; }; theme.extraConfig = let name = "theme-matugen"; in lib.mkBefore "${pkgs.writeShellApplication { inherit name; runtimeInputs = with pkgs; [ matugen ]; text = '' matugen image "${hmConfig.theme.configDir}/wallpaper" \ --type scheme-${hmConfig.theme.flavour} \ --mode "$(cat "${hmConfig.theme.configDir}/mode")" \ --contrast ${builtins.toString hmConfig.theme.contrast} ''; }}/bin/${name}"; }; }