Files
nix/users/configs/matugen/default.nix
2024-07-02 19:30:22 +03:00

79 lines
3.0 KiB
Nix

{ 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 =
let
zeroPad = hex: if builtins.stringLength hex == 1 then "0${hex}" else hex;
percentageToHex = percentage: zeroPad (lib.trivial.toHexString (builtins.floor (percentage * 255)));
in
{
flavour = hmConfig.theme.flavour;
contrast = builtins.toString hmConfig.theme.contrast;
radius = builtins.toString hmConfig.theme.radius;
padding = builtins.toString hmConfig.theme.padding;
padding_double = builtins.toString (hmConfig.theme.padding * 2);
blur = builtins.toString hmConfig.theme.blur;
opacity = builtins.toString hmConfig.theme.opacity;
opacity_hex = builtins.toString (percentageToHex hmConfig.theme.opacity);
opacity_shadow = builtins.toString (hmConfig.theme.opacity * .75);
opacity_shadow_hex = builtins.toString (percentageToHex (hmConfig.theme.opacity * .75));
font_size = builtins.toString hmConfig.theme.font.size;
};
};
templates = { };
};
};
theme.extraConfig = lib.mkBefore (lib.meta.getExe (pkgs.writeShellApplication {
name = "theme-matugen";
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}
'';
}));
};
}