From e73f4c08322acf31bec1bb15d5ef3d0c13eb6be9 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:40:10 -0700 Subject: [PATCH 01/22] chromium: use mkTarget --- modules/chromium/nixos.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/chromium/nixos.nix b/modules/chromium/nixos.nix index a8fd3b8e..d0d2201b 100644 --- a/modules/chromium/nixos.nix +++ b/modules/chromium/nixos.nix @@ -1,16 +1,17 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "chromium"; + humanName = "Chromium, Google Chrome and Brave"; -{ - options.stylix.targets.chromium.enable = - config.lib.stylix.mkEnableTarget "Chromium, Google Chrome and Brave" true; - - config.programs.chromium = - lib.mkIf (config.stylix.enable && config.stylix.targets.chromium.enable) - { + configElements = + { colors }: + { + programs.chromium = { # This enables policies without installing the browser. Policies take up a # negligible amount of space, so it's reasonable to have this always on. enable = true; - extraOpts.BrowserThemeColor = config.lib.stylix.colors.withHashtag.base00; + extraOpts.BrowserThemeColor = colors.withHashtag.base00; }; + }; } From 085767cc84bea0742dd21c339f006fe7a8773266 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:40:18 -0700 Subject: [PATCH 02/22] gedit: use mkTarget --- modules/gedit/hm.nix | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/modules/gedit/hm.nix b/modules/gedit/hm.nix index c3962322..1a2ec264 100644 --- a/modules/gedit/hm.nix +++ b/modules/gedit/hm.nix @@ -1,19 +1,16 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "gedit"; + humanName = "GEdit"; -let - style = config.lib.stylix.colors { - template = ./template.xml.mustache; - extension = ".xml"; - }; - -in -{ - options.stylix.targets.gedit.enable = - config.lib.stylix.mkEnableTarget "GEdit" true; - - config = lib.mkIf (config.stylix.enable && config.stylix.targets.gedit.enable) { - xdg.dataFile = { - "gedit/styles/stylix.xml".source = style; + configElements = + { colors }: + { + xdg.dataFile = { + "gedit/styles/stylix.xml".source = colors { + template = ./template.xml.mustache; + extension = ".xml"; + }; + }; }; - }; } From cde06bed949235cae1d22ac02ec2cf415c619dd1 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:40:23 -0700 Subject: [PATCH 03/22] gitui: use mkTarget --- modules/gitui/hm.nix | 64 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/modules/gitui/hm.nix b/modules/gitui/hm.nix index 73cbadc4..7246cd04 100644 --- a/modules/gitui/hm.nix +++ b/modules/gitui/hm.nix @@ -1,33 +1,35 @@ -{ config, lib, ... }: -{ - options.stylix.targets.gitui.enable = - config.lib.stylix.mkEnableTarget "GitUI" true; +{ mkTarget, ... }: +mkTarget { + name = "gitui"; + humanName = "GitUI"; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.gitui.enable) { - programs.gitui.theme = with config.lib.stylix.colors.withHashtag; '' - ( - selected_tab: Some("Reset"), - command_fg: Some("${base05}"), - selection_bg: Some("${base04}"), - selection_fg: Some("${base05}"), - cmdbar_bg: Some("${base01}"), - cmdbar_extra_lines_bg: Some("${base01}"), - disabled_fg: Some("${base04}"), - diff_line_add: Some("${base0B}"), - diff_line_delete: Some("${base08}"), - diff_file_added: Some("${base0A}"), - diff_file_removed: Some("${base08}"), - diff_file_moved: Some("${base0E}"), - diff_file_modified: Some("${base09}"), - commit_hash: Some("${base07}"), - commit_time: Some("${base05}"), - commit_author: Some("${base0D}"), - danger_fg: Some("${base08}"), - push_gauge_bg: Some("${base0D}"), - push_gauge_fg: Some("${base00}"), - tag_fg: Some("${base06}"), - branch_fg: Some("${base0C}") - ) - ''; - }; + configElements = + { colors }: + { + programs.gitui.theme = with colors.withHashtag; '' + ( + selected_tab: Some("Reset"), + command_fg: Some("${base05}"), + selection_bg: Some("${base04}"), + selection_fg: Some("${base05}"), + cmdbar_bg: Some("${base01}"), + cmdbar_extra_lines_bg: Some("${base01}"), + disabled_fg: Some("${base04}"), + diff_line_add: Some("${base0B}"), + diff_line_delete: Some("${base08}"), + diff_file_added: Some("${base0A}"), + diff_file_removed: Some("${base08}"), + diff_file_moved: Some("${base0E}"), + diff_file_modified: Some("${base09}"), + commit_hash: Some("${base07}"), + commit_time: Some("${base05}"), + commit_author: Some("${base0D}"), + danger_fg: Some("${base08}"), + push_gauge_bg: Some("${base0D}"), + push_gauge_fg: Some("${base00}"), + tag_fg: Some("${base06}"), + branch_fg: Some("${base0C}") + ) + ''; + }; } From 24d1438df48064b9c258429339cac2fbe62723c4 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:40:28 -0700 Subject: [PATCH 04/22] halloy: use mkTarget --- modules/halloy/hm.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/halloy/hm.nix b/modules/halloy/hm.nix index d98c551e..b91f02c5 100644 --- a/modules/halloy/hm.nix +++ b/modules/halloy/hm.nix @@ -1,13 +1,14 @@ -{ config, lib, ... }: -{ - options.stylix.targets.halloy.enable = - config.lib.stylix.mkEnableTarget "Halloy" true; +{ mkTarget, ... }: +mkTarget { + name = "halloy"; + humanName = "Halloy"; - config.programs.halloy = - lib.mkIf (config.stylix.enable && config.stylix.targets.halloy.enable) - { + configElements = + { colors }: + { + programs.halloy = { settings.theme = "stylix"; - themes.stylix = with config.lib.stylix.colors.withHashtag; { + themes.stylix = with colors.withHashtag; { general = { background = base00; border = base07; @@ -58,4 +59,5 @@ }; }; }; + }; } From 26efa4fca0ecc163697c388b2975138e9bb01053 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:40:51 -0700 Subject: [PATCH 05/22] helix: use mkTarget --- modules/helix/hm.nix | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/modules/helix/hm.nix b/modules/helix/hm.nix index 96c48eea..7d583b6d 100644 --- a/modules/helix/hm.nix +++ b/modules/helix/hm.nix @@ -1,28 +1,39 @@ { + mkTarget, pkgs, - config, lib, ... }: -{ - options.stylix.targets.helix.enable = - config.lib.stylix.mkEnableTarget "Helix" true; +mkTarget { + name = "helix"; + humanName = "Helix"; - config = - lib.mkIf - ( - config.stylix.enable - && config.stylix.targets.helix.enable - && config.programs.helix.enable - ) + extraOptions.transparent = lib.mkEnableOption "transparent theming" // { + internal = true; + default = false; + }; + + configElements = [ + ( + { opacity }: + { + stylix.targets.helix.transparent = opacity.terminal != 1.0; + } + ) + ( + { + cfg, + colors, + inputs, + }: { programs.helix = { settings.theme = "stylix"; themes.stylix = let - theme = config.lib.stylix.colors { - templateRepo = config.stylix.inputs.base16-helix; + theme = colors { + templateRepo = inputs.base16-helix; }; # Removing the background exposes transparency from the terminal. The @@ -32,7 +43,9 @@ sed 's/,\? bg = "base00"//g' <${theme} >$out ''; in - if config.stylix.opacity.terminal == 1.0 then theme else transparentTheme; + if cfg.transparent then transparentTheme else theme; }; - }; + } + ) + ]; } From 81cb57a350da029d168535afd0342e8625ea6a2a Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:40:58 -0700 Subject: [PATCH 06/22] hyprlock: use mkTraget --- modules/hyprlock/hm.nix | 58 +++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/modules/hyprlock/hm.nix b/modules/hyprlock/hm.nix index 083ce28e..b9d127fb 100644 --- a/modules/hyprlock/hm.nix +++ b/modules/hyprlock/hm.nix @@ -1,26 +1,40 @@ -{ config, lib, ... }: -let - cfg = config.stylix.targets.hyprlock; -in { - options.stylix.targets.hyprlock = with config.lib.stylix; { - enable = mkEnableTarget "Hyprlock" true; - useWallpaper = mkEnableWallpaper "Hyprlock" true; + mkTarget, + config, + lib, + ... +}: +mkTarget { + name = "hyprlock"; + humanName = "Hyprlock"; + + extraOptions = { + useWallpaper = config.lib.stylix.mkEnableWallpaper "Hyprlock" true; }; - config = lib.mkIf (config.stylix.enable && cfg.enable) { - programs.hyprlock.settings = with config.lib.stylix.colors; { - background = { - color = "rgb(${base00})"; - path = lib.mkIf cfg.useWallpaper "${config.stylix.image}"; - }; - input-field = { - outer_color = "rgb(${base03})"; - inner_color = "rgb(${base00})"; - font_color = "rgb(${base05})"; - fail_color = "rgb(${base08})"; - check_color = "rgb(${base0A})"; - }; - }; - }; + configElements = [ + ( + { cfg, image }: + { + programs.hyprlock.settings.path = lib.mkIf cfg.useWallpaper "${image}"; + } + ) + ( + { colors }: + { + programs.hyprlock.settings = with colors; { + background = { + color = "rgb(${base00})"; + }; + input-field = { + outer_color = "rgb(${base03})"; + inner_color = "rgb(${base00})"; + font_color = "rgb(${base05})"; + fail_color = "rgb(${base08})"; + check_color = "rgb(${base0A})"; + }; + }; + } + ) + ]; } From 910dc0dc3e9792ca9fe143fed318b59ac7857f9c Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:52:03 -0700 Subject: [PATCH 07/22] btop: use mkTarget --- modules/btop/hm.nix | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/modules/btop/hm.nix b/modules/btop/hm.nix index 902d6f78..7e804c0d 100644 --- a/modules/btop/hm.nix +++ b/modules/btop/hm.nix @@ -1,22 +1,27 @@ -{ config, lib, ... }: { - options.stylix.targets.btop.enable = - config.lib.stylix.mkEnableTarget "btop" true; + mkTarget, + lib, + ... +}: +mkTarget { + name = "btop"; + humanName = "btop"; - config = - lib.mkIf - ( - config.stylix.enable - && config.stylix.targets.btop.enable - && config.programs.btop.enable - ) + configElements = [ + ( + { opacity }: + { + programs.btop.settings.theme_background = lib.mkIf ( + opacity.terminal != 1.0 + ) false; + } + ) + ( + { colors }: { programs.btop = { - settings = { - color_theme = "stylix"; - theme_background = lib.mkIf (config.stylix.opacity.terminal != 1.0) false; - }; - themes.stylix = with config.lib.stylix.colors.withHashtag; '' + settings.color_theme = "stylix"; + themes.stylix = with colors.withHashtag; '' #Generated by Stylix theme[main_bg]="${base00}" theme[main_fg]="${base05}" @@ -62,5 +67,7 @@ theme[process_end]="${base08}" ''; }; - }; + } + ) + ]; } From 89edd2f3c0b6e921aebf3ebe02fbc73a057345f5 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:56:38 -0700 Subject: [PATCH 08/22] foot: use mkTarget --- modules/foot/hm.nix | 47 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/modules/foot/hm.nix b/modules/foot/hm.nix index 7873b15d..ba9332f7 100644 --- a/modules/foot/hm.nix +++ b/modules/foot/hm.nix @@ -1,20 +1,31 @@ -{ config, lib, ... }: -{ - options.stylix.targets.foot.enable = - config.lib.stylix.mkEnableTarget "Foot" true; +{ mkTarget, ... }: +mkTarget { + name = "foot"; + humanName = "Foot"; - config.programs.foot.settings = lib.mkIf config.stylix.targets.foot.enable { - main = { - include = toString ( - config.lib.stylix.colors { - templateRepo = config.stylix.inputs.tinted-foot; - } - ); - font = - with config.stylix.fonts; - "${monospace.name}:size=${toString sizes.terminal}"; - dpi-aware = "no"; - }; - colors.alpha = config.stylix.opacity.terminal; - }; + configElements = [ + ( + { fonts }: + { + programs.foot.settings.main = { + font = "${fonts.monospace.name}:=size=${toString fonts.sizes.terminal}"; + dpi-aware = "no"; + }; + } + ) + ( + { opacity }: + { + programs.foot.settings.colors.alpha = opacity.terminal; + } + ) + ( + { colors, inputs }: + { + programs.foot.settings.main.include = toString (colors { + templateRepo = inputs.tinted-foot; + }); + } + ) + ]; } From af114357237b03f5c2979ac170224b3c979650f9 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 13:57:49 -0700 Subject: [PATCH 09/22] lazygit: use mkTarget --- modules/lazygit/hm.nix | 53 +++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/modules/lazygit/hm.nix b/modules/lazygit/hm.nix index baaf6390..f35c0b06 100644 --- a/modules/lazygit/hm.nix +++ b/modules/lazygit/hm.nix @@ -1,32 +1,27 @@ -{ - config, - lib, - ... -}: -{ - options.stylix.targets.lazygit.enable = - config.lib.stylix.mkEnableTarget "lazygit" true; +{ mkTarget, ... }: +mkTarget { + name = "lazygit"; + humanName = "lazygit"; - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.lazygit.enable) - { - programs.lazygit.settings.gui.theme = - with config.lib.stylix.colors.withHashtag; { - activeBorderColor = [ - base07 - "bold" - ]; - inactiveBorderColor = [ base04 ]; - searchingActiveBorderColor = [ - base02 - "bold" - ]; - optionsTextColor = [ base06 ]; - selectedLineBgColor = [ base03 ]; - cherryPickedCommitBgColor = [ base02 ]; - cherryPickedCommitFgColor = [ base03 ]; - unstagedChangesColor = [ base08 ]; - defaultFgColor = [ base05 ]; - }; + configElements = + { colors }: + { + programs.lazygit.settings.gui.theme = with colors.withHashtag; { + activeBorderColor = [ + base07 + "bold" + ]; + inactiveBorderColor = [ base04 ]; + searchingActiveBorderColor = [ + base02 + "bold" + ]; + optionsTextColor = [ base06 ]; + selectedLineBgColor = [ base03 ]; + cherryPickedCommitBgColor = [ base02 ]; + cherryPickedCommitFgColor = [ base03 ]; + unstagedChangesColor = [ base08 ]; + defaultFgColor = [ base05 ]; }; + }; } From 18211a9f417e7cf08dcda2f350000278ddae1794 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:01:23 -0700 Subject: [PATCH 10/22] fish: use mkTarget --- modules/fish/hm.nix | 19 +++++++++++-------- modules/fish/nixos.nix | 17 +++++++++-------- modules/fish/prompt.nix | 9 +++------ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/modules/fish/hm.nix b/modules/fish/hm.nix index 4493aecc..9763c50b 100644 --- a/modules/fish/hm.nix +++ b/modules/fish/hm.nix @@ -1,10 +1,13 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "fish"; + humanName = "Fish"; -{ - options.stylix.targets.fish.enable = - config.lib.stylix.mkEnableTarget "Fish" true; - - config = lib.mkIf (config.stylix.enable && config.stylix.targets.fish.enable) { - programs.fish.interactiveShellInit = import ./prompt.nix config; - }; + configElements = + { colors, inputs }: + { + programs.fish.interactiveShellInit = import ./prompt.nix { + inherit colors inputs; + }; + }; } diff --git a/modules/fish/nixos.nix b/modules/fish/nixos.nix index 2fa26dd9..02affea0 100644 --- a/modules/fish/nixos.nix +++ b/modules/fish/nixos.nix @@ -1,10 +1,11 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "fish"; + humanName = "Fish"; -{ - options.stylix.targets.fish.enable = - config.lib.stylix.mkEnableTarget "Fish" true; - - config = lib.mkIf (config.stylix.enable && config.stylix.targets.fish.enable) { - programs.fish.promptInit = import ./prompt.nix config; - }; + configElements = + { colors, inputs }: + { + programs.fish.promptInit = import ./prompt.nix { inherit colors inputs; }; + }; } diff --git a/modules/fish/prompt.nix b/modules/fish/prompt.nix index d2026335..468e9426 100644 --- a/modules/fish/prompt.nix +++ b/modules/fish/prompt.nix @@ -1,15 +1,12 @@ -config: - +{ colors, inputs }: let - theme = config.lib.stylix.colors { - templateRepo = config.stylix.inputs.base16-fish; - }; + theme = colors { templateRepo = inputs.base16-fish; }; in '' source ${theme} # See https://github.com/tomyun/base16-fish/issues/7 for why this condition exists if status --is-interactive && test -z "$TMUX" - base16-${config.lib.stylix.colors.slug} + base16-${colors.slug} end '' From 02f3d00467af0f4269d6ee1c80a28cfd15757b4a Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:02:23 -0700 Subject: [PATCH 11/22] foliate: use mkTarget --- modules/foliate/hm.nix | 45 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/modules/foliate/hm.nix b/modules/foliate/hm.nix index 4b53d46d..43ce4f3d 100644 --- a/modules/foliate/hm.nix +++ b/modules/foliate/hm.nix @@ -1,30 +1,29 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "foliate"; + humanName = "Foliate"; -{ - options.stylix.targets.foliate.enable = - config.lib.stylix.mkEnableTarget "Foliate" true; + configElements = + { colors }: + { + programs.foliate = { + settings."viewer/view" = { + theme = "stylix.json"; + }; - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.foliate.enable) - { - programs.foliate = { - settings."viewer/view" = { - theme = "stylix.json"; + themes.stylix = with colors.withHashtag; { + label = "Stylix"; + light = { + fg = base00; + bg = base05; + link = base0D; }; - - themes.stylix = with config.lib.stylix.colors.withHashtag; { - label = "Stylix"; - light = { - fg = base00; - bg = base05; - link = base0D; - }; - dark = { - fg = base05; - bg = base00; - link = base0D; - }; + dark = { + fg = base05; + bg = base00; + link = base0D; }; }; }; + }; } From e31bca3ee1295cb7fdddef01332eeeaea1e9d6b6 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:06:13 -0700 Subject: [PATCH 12/22] bspwm: use mkTarget --- modules/bspwm/hm.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/bspwm/hm.nix b/modules/bspwm/hm.nix index 2df8691a..fb51e970 100644 --- a/modules/bspwm/hm.nix +++ b/modules/bspwm/hm.nix @@ -1,15 +1,16 @@ -{ config, lib, ... }: -{ - options.stylix.targets.bspwm.enable = - config.lib.stylix.mkEnableTarget "bspwm" true; +{ mkTarget, ... }: +mkTarget { + name = "bspwm"; + humanName = "bspwm"; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.bspwm.enable) { - xsession.windowManager.bspwm.settings = - with config.lib.stylix.colors.withHashtag; { + configElements = + { colors }: + { + xsession.windowManager.bspwm.settings = with colors.withHashtag; { normal_border_color = base03; active_border_color = base0C; focused_border_color = base0D; presel_feedback_color = base00; }; - }; + }; } From 33c517c8ec646135a9b88a009b60d76582cb74d1 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:08:10 -0700 Subject: [PATCH 13/22] xfce: use mkTarget --- modules/xfce/hm.nix | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/modules/xfce/hm.nix b/modules/xfce/hm.nix index 0790a80d..0eeae1b7 100644 --- a/modules/xfce/hm.nix +++ b/modules/xfce/hm.nix @@ -1,19 +1,21 @@ -{ config, lib, ... }: - -{ +{ mkTarget, ... }: +mkTarget { + name = "xfce"; + humanName = "Xfce"; # Disabled by default due to https://github.com/nix-community/stylix/issues/180 - options.stylix.targets.xfce.enable = - config.lib.stylix.mkEnableTarget "Xfce" false; + autoEnable = false; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.xfce.enable) { - xfconf.settings = with config.stylix.fonts; { - xfwm4 = { - "general/title_font" = "${sansSerif.name} ${toString sizes.desktop}"; - }; - xsettings = { - "Gtk/FontName" = "${sansSerif.name} ${toString sizes.applications}"; - "Gtk/MonospaceFontName" = "${monospace.name} ${toString sizes.applications}"; + configElements = + { fonts }: + { + xfconf.settings = with fonts; { + xfwm4 = { + "general/title_font" = "${sansSerif.name} ${toString sizes.desktop}"; + }; + xsettings = { + "Gtk/FontName" = "${sansSerif.name} ${toString sizes.applications}"; + "Gtk/MonospaceFontName" = "${monospace.name} ${toString sizes.applications}"; + }; }; }; - }; } From fea4b0ea5870f3826987cdd266a61894a27cf54e Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:09:58 -0700 Subject: [PATCH 14/22] xresources: use mkTarget --- modules/xresources/hm.nix | 78 ++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/modules/xresources/hm.nix b/modules/xresources/hm.nix index de6d8629..b8ae62d7 100644 --- a/modules/xresources/hm.nix +++ b/modules/xresources/hm.nix @@ -1,40 +1,44 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "xresources"; + humanName = "Xresources"; -{ - options.stylix.targets.xresources.enable = - config.lib.stylix.mkEnableTarget "Xresources" true; - - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.xresources.enable) + configElements = [ + ( + { fonts }: { - xresources.properties = - let - inherit (config.stylix) fonts; - in - with config.lib.stylix.colors.withHashtag; - { - "*.faceName" = fonts.monospace.name; - "*.faceSize" = toString fonts.sizes.terminal; - "*.renderFont" = true; - "*foreground" = base05; - "*background" = base00; - "*cursorColor" = base05; - "*color0" = base00; - "*color1" = base08; - "*color2" = base0B; - "*color3" = base0A; - "*color4" = base0D; - "*color5" = base0E; - "*color6" = base0C; - "*color7" = base05; - "*color8" = base03; - "*color9" = base09; - "*color10" = base01; - "*color11" = base02; - "*color12" = base04; - "*color13" = base06; - "*color14" = base0F; - "*color15" = base07; - }; - }; + xresources.properties = { + "*.faceName" = fonts.monospace.name; + "*.faceSize" = toString fonts.sizes.terminal; + "*.renderFont" = true; + }; + } + ) + ( + { colors }: + { + xresources.properties = with colors.withHashtag; { + "*foreground" = base05; + "*background" = base00; + "*cursorColor" = base05; + "*color0" = base00; + "*color1" = base08; + "*color2" = base0B; + "*color3" = base0A; + "*color4" = base0D; + "*color5" = base0E; + "*color6" = base0C; + "*color7" = base05; + "*color8" = base03; + "*color9" = base09; + "*color10" = base01; + "*color11" = base02; + "*color12" = base04; + "*color13" = base06; + "*color14" = base0F; + "*color15" = base07; + }; + } + ) + ]; } From 019d9f11b3e23b9814de65633d00763af0aea23f Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:10:53 -0700 Subject: [PATCH 15/22] zellij: use mkTarget --- modules/zellij/hm.nix | 51 +++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/modules/zellij/hm.nix b/modules/zellij/hm.nix index 1adc0776..1ad01f4b 100644 --- a/modules/zellij/hm.nix +++ b/modules/zellij/hm.nix @@ -1,34 +1,27 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "zellij"; + humanName = "zellij"; -{ - options.stylix.targets.zellij.enable = - config.lib.stylix.mkEnableTarget "zellij" true; - - config = - lib.mkIf - ( - config.stylix.enable - && config.stylix.targets.zellij.enable - && config.programs.zellij.enable - ) - { - programs.zellij.themes.stylix = { - themes = with config.lib.stylix.colors.withHashtag; { - default = { - bg = base03; - fg = base05; - red = base01; - green = base0B; - blue = base0D; - yellow = base0A; - magenta = base0E; - orange = base09; - cyan = base0C; - black = base00; - white = base07; - }; + configElements = + { colors }: + { + programs.zellij.themes.stylix = { + themes = with colors.withHashtag; { + default = { + bg = base03; + fg = base05; + red = base01; + green = base0B; + blue = base0D; + yellow = base0A; + magenta = base0E; + orange = base09; + cyan = base0C; + black = base00; + white = base07; }; }; }; - + }; } From 68518231f323a3a47d07a087c7a9711d2fa655d0 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:13:26 -0700 Subject: [PATCH 16/22] zed: use mkTarget --- modules/zed/hm.nix | 55 ++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/modules/zed/hm.nix b/modules/zed/hm.nix index fd60340c..2b864190 100644 --- a/modules/zed/hm.nix +++ b/modules/zed/hm.nix @@ -1,35 +1,32 @@ -{ - config, - lib, - ... -}: -{ - options.stylix.targets.zed.enable = config.lib.stylix.mkEnableTarget "zed" true; +{ mkTarget, ... }: +mkTarget { + name = "zed"; + humanName = "zed"; - config = - lib.mkIf - ( - config.stylix.enable - && config.stylix.targets.zed.enable - && config.programs.zed-editor.enable - ) + configElements = [ + ( + { fonts }: { programs.zed-editor = { - userSettings = - let - inherit (config.stylix) fonts; - in - { - "buffer_font_family" = fonts.monospace.name; - "buffer_font_size" = fonts.sizes.terminal * 4.0 / 3.0; - "theme" = "Base16 ${config.lib.stylix.colors.scheme-name}"; - "ui_font_family" = fonts.sansSerif.name; - "ui_font_size" = fonts.sizes.applications * 4.0 / 3.0; - }; - - themes.stylix = config.lib.stylix.colors { - templateRepo = config.stylix.inputs.tinted-zed; + userSettings = { + "buffer_font_family" = fonts.monospace.name; + "buffer_font_size" = fonts.sizes.terminal * 4.0 / 3.0; + "ui_font_family" = fonts.sansSerif.name; + "ui_font_size" = fonts.sizes.applications * 4.0 / 3.0; }; }; - }; + } + ) + ( + { colors, inputs }: + { + programs.zed-editor = { + userSettings.theme = "Base16 ${colors.scheme-name}"; + themes.stylix = colors { + templateRepo = inputs.tinted-zed; + }; + }; + } + ) + ]; } From e0e61f8c97a4b124646b596e64e6d0454f1fa771 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:20:11 -0700 Subject: [PATCH 17/22] cavalier: use mkTarget --- modules/cavalier/hm.nix | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/modules/cavalier/hm.nix b/modules/cavalier/hm.nix index b41fdfc9..e5979cc7 100644 --- a/modules/cavalier/hm.nix +++ b/modules/cavalier/hm.nix @@ -1,23 +1,18 @@ -{ config, lib, ... }: +{ mkTarget, lib, ... }: +mkTarget { + name = "cavalier"; + humanName = "Cavalier"; -{ - options.stylix.targets.cavalier.enable = - config.lib.stylix.mkEnableTarget "Cavalier" true; - - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.cavalier.enable) - { - programs.cavalier.settings.general = { - ColorProfiles = - let - inherit (config.lib.stylix) colors; - in - lib.singleton { - Name = "Stylix"; - FgColors = [ colors.base05 ]; - BgColors = [ colors.base00 ]; - }; - ActiveProfile = 0; + configElements = + { colors }: + { + programs.cavalier.settings.general = { + ColorProfiles = lib.singleton { + Name = "Stylix"; + FgColors = [ colors.base05 ]; + BgColors = [ colors.base00 ]; }; + ActiveProfile = 0; }; + }; } From f4a4b2690c1bd8dfab734f533df9a668f9c7f027 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:30:31 -0700 Subject: [PATCH 18/22] avizo: use mkTarget --- modules/avizo/hm.nix | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/avizo/hm.nix b/modules/avizo/hm.nix index 83633a0a..25900638 100644 --- a/modules/avizo/hm.nix +++ b/modules/avizo/hm.nix @@ -1,22 +1,18 @@ -{ - config, - lib, - options, - ... -}: -{ - options.stylix.targets.avizo.enable = - config.lib.stylix.mkEnableTarget "Avizo" true; +{ mkTarget, ... }: +mkTarget { + name = "avizo"; + humanName = "Avizo"; # Referenced https://github.com/stacyharper/base16-mako - config = lib.optionalAttrs (options.services ? avizo) ( - lib.mkIf (config.stylix.enable && config.stylix.targets.avizo.enable) { + configElements = + { colors, opacity }: + { services.avizo = { settings = { default = - with config.lib.stylix.colors; + with colors; let - aviOpacity = toString config.stylix.opacity.popups; + aviOpacity = toString opacity.popups; in { background = "rgba(${base01-rgb-r}, ${base01-rgb-g}, ${base01-rgb-b}, ${aviOpacity})"; @@ -27,6 +23,5 @@ }; }; }; - } - ); + }; } From 3d5c02f843384aa647c52d7532eb9ca18a2299c5 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:30:35 -0700 Subject: [PATCH 19/22] bat: use mkTarget --- modules/bat/hm.nix | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/bat/hm.nix b/modules/bat/hm.nix index 074831c6..ff424fca 100644 --- a/modules/bat/hm.nix +++ b/modules/bat/hm.nix @@ -1,18 +1,20 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "bat"; + humanName = "Bat"; -{ - options.stylix.targets.bat.enable = config.lib.stylix.mkEnableTarget "Bat" true; + configElements = + { colors }: + { + programs.bat = { + # This theme is reused for yazi. Changes to the template + # will need to be applied to modules/yazi/hm.nix + themes."base16-stylix".src = colors { + template = ./base16-stylix.tmTheme.mustache; + extension = ".tmTheme"; + }; - config = lib.mkIf (config.stylix.enable && config.stylix.targets.bat.enable) { - programs.bat = { - # This theme is reused for yazi. Changes to the template - # will need to be applied to modules/yazi/hm.nix - themes."base16-stylix".src = config.lib.stylix.colors { - template = ./base16-stylix.tmTheme.mustache; - extension = ".tmTheme"; + config.theme = "base16-stylix"; }; - - config.theme = "base16-stylix"; }; - }; } From 7b2e482da7d32a9f092a67c8a669a4092406cc62 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:30:42 -0700 Subject: [PATCH 20/22] cava: use mkTarget --- modules/cava/hm.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/cava/hm.nix b/modules/cava/hm.nix index 50796190..df535fff 100644 --- a/modules/cava/hm.nix +++ b/modules/cava/hm.nix @@ -1,14 +1,15 @@ -{ config, lib, ... }: -{ - options.stylix.targets.cava = { - enable = config.lib.stylix.mkEnableTarget "CAVA" true; +{ mkTarget, lib, ... }: +mkTarget { + name = "cava"; + humanName = "CAVA"; + + extraOptions = { rainbow.enable = lib.mkEnableOption "rainbow gradient theming"; }; - config = + configElements = + { cfg, colors }: let - cfg = config.stylix.targets.cava; - mkGradient = colors: lib.listToAttrs ( @@ -21,10 +22,10 @@ gradient_count = builtins.length colors; }; in - lib.mkIf (config.stylix.enable && cfg.enable) { + { programs.cava.settings.color = lib.mkIf cfg.rainbow.enable ( mkGradient ( - with config.lib.stylix.colors; + with colors; [ base0E base0D From 59c782eb99aa14cc5f21263ffe4f4974aaee2fea Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:30:49 -0700 Subject: [PATCH 21/22] console: use mkTarget --- modules/console/droid.nix | 61 +++++++++++++++++++-------------------- modules/console/nixos.nix | 50 +++++++++++++++++--------------- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/modules/console/droid.nix b/modules/console/droid.nix index 9e934ef8..caf1f42d 100644 --- a/modules/console/droid.nix +++ b/modules/console/droid.nix @@ -1,36 +1,35 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "console"; + humanName = "the Nix-on-Droid console"; -{ - options.stylix.targets.console.enable = - config.lib.stylix.mkEnableTarget "the Nix-on-Droid console" true; + configElements = + { colors }: + { + terminal.colors = with colors.withHashtag; rec { + background = base00; + foreground = base05; + cursor = base05; - config = - lib.mkIf (config.stylix.enable && config.stylix.targets.console.enable) - { - terminal.colors = with config.lib.stylix.colors.withHashtag; rec { - background = base00; - foreground = base05; - cursor = base05; + # normal + color0 = base00; + color1 = base08; + color2 = base0B; + color3 = base0A; + color4 = base0D; + color5 = base0E; + color6 = base0C; + color7 = base05; - # normal - color0 = base00; - color1 = base08; - color2 = base0B; - color3 = base0A; - color4 = base0D; - color5 = base0E; - color6 = base0C; - color7 = base05; - - # bright - color8 = base02; - color9 = color1; - color10 = color2; - color11 = color3; - color12 = color4; - color13 = color5; - color14 = color6; - color15 = base07; - }; + # bright + color8 = base02; + color9 = color1; + color10 = color2; + color11 = color3; + color12 = color4; + color13 = color5; + color14 = color6; + color15 = base07; }; + }; } diff --git a/modules/console/nixos.nix b/modules/console/nixos.nix index 2b49f165..f854ca15 100644 --- a/modules/console/nixos.nix +++ b/modules/console/nixos.nix @@ -1,26 +1,28 @@ -{ config, lib, ... }: -{ - options.stylix.targets.console.enable = - config.lib.stylix.mkEnableTarget "the Linux kernel console" true; +{ mkTarget, ... }: +mkTarget { + name = "console"; + humanName = "the Linux kernel console"; - config.console.colors = - with config.lib.stylix.colors; - lib.mkIf (config.stylix.enable && config.stylix.targets.console.enable) [ - base00-hex - red - green - yellow - blue - magenta - cyan - base05-hex - base03-hex - red - green - yellow - blue - magenta - cyan - base06-hex - ]; + configElements = + { colors }: + { + console.colors = with colors; [ + base00-hex + red + green + yellow + blue + magenta + cyan + base05-hex + base03-hex + red + green + yellow + blue + magenta + cyan + base06-hex + ]; + }; } From 6f67462b01bb8d37749f4c0c0cb77b6799054808 Mon Sep 17 00:00:00 2001 From: awwpotato Date: Wed, 21 May 2025 14:38:58 -0700 Subject: [PATCH 22/22] forge: use mkTarget --- modules/forge/hm.nix | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/forge/hm.nix b/modules/forge/hm.nix index 03b4932f..04000a72 100644 --- a/modules/forge/hm.nix +++ b/modules/forge/hm.nix @@ -1,15 +1,14 @@ -{ config, lib, ... }: +{ mkTarget, ... }: +mkTarget { + name = "forge"; + humanName = "Forge"; -{ - options.stylix.targets.forge.enable = - config.lib.stylix.mkEnableTarget "Forge" true; - - config = lib.mkIf (config.stylix.enable && config.stylix.targets.forge.enable) { - xdg.configFile."forge/stylesheet/forge/stylesheet.css".source = - config.lib.stylix.colors - { - template = ./stylesheet.css.mustache; - extension = ".css"; - }; - }; + configElements = + { colors }: + { + xdg.configFile."forge/stylesheet/forge/stylesheet.css".source = colors { + template = ./stylesheet.css.mustache; + extension = ".css"; + }; + }; }