From 98434b79cf7dbedb8f5d78729324cb2b5bbf8b88 Mon Sep 17 00:00:00 2001 From: Sweetbread Date: Mon, 8 Jun 2026 03:24:54 +0300 Subject: [PATCH] stylix: add accent color I spent an hour just to add one f*ing option --- modules/user.nix | 1 + modules/user/packages/drvs/ags.nix | 8 ++---- modules/user/stylix.nix | 40 ++++++++++++++++++++++++++++ user/chest/modules/hyprland.nix | 3 ++- user/chest/modules/style.nix | 1 + user/chest/modules/waybar.nix | 2 +- user/sweetbread/modules/hyprland.nix | 3 ++- user/sweetbread/modules/style.nix | 1 + user/sweetbread/modules/waybar.nix | 11 ++++---- 9 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 modules/user/stylix.nix diff --git a/modules/user.nix b/modules/user.nix index d1f0da3..2d7ea75 100644 --- a/modules/user.nix +++ b/modules/user.nix @@ -9,6 +9,7 @@ ./user/neofetch.nix ./user/qt.nix ./user/quickshell.nix + ./user/stylix.nix ./user/sops.nix ./user/ssh.nix ./user/walker.nix diff --git a/modules/user/packages/drvs/ags.nix b/modules/user/packages/drvs/ags.nix index 04ebf85..8c343a4 100644 --- a/modules/user/packages/drvs/ags.nix +++ b/modules/user/packages/drvs/ags.nix @@ -1,15 +1,11 @@ -{ stdenv, lib, config, colors, username, ... }: +{ stdenv, colors, accent ? colors.base0B, ... }: stdenv.mkDerivation { name = "AGS theme"; src = ./ags; dontUnpack = true; - patchPhase = let - accent = if username == "chest" - then colors.base0E - else colors.base0B; - in '' + patchPhase = '' echo \$bg: \#${colors.base00}\; > colors.scss echo \$surface0: \#${colors.base02}\; >> colors.scss echo \$fg: \#${colors.base05}\; >> colors.scss diff --git a/modules/user/stylix.nix b/modules/user/stylix.nix new file mode 100644 index 0000000..edd3e1c --- /dev/null +++ b/modules/user/stylix.nix @@ -0,0 +1,40 @@ +{ config, lib, ... }: let + inherit (lib) mkOption types; + + base16Names = [ + "base00" + "base01" + "base02" + "base03" + "base04" + "base05" + "base06" + "base07" + "base08" + "base09" + "base0A" + "base0B" + "base0C" + "base0D" + "base0E" + "base0F" + ]; +in { + options.stylix.accent = mkOption { + type = types.enum base16Names; + default = "base0B"; + description = '' + Base16 colour used as the user accent. + + Use it as: + + config.lib.stylix.colors.${config.stylix.accent} + config.lib.stylix.colors.withHashtag.${config.stylix.accent} + + This module deliberately does not extend config.lib.stylix.colors: Stylix + exports that value as a generated base16 attrset/functor, and replacing or + partially extending it can break Stylix targets which expect metadata such + as `scheme` to be present. + ''; + }; +} diff --git a/user/chest/modules/hyprland.nix b/user/chest/modules/hyprland.nix index 3cc09cc..5ee382c 100644 --- a/user/chest/modules/hyprland.nix +++ b/user/chest/modules/hyprland.nix @@ -1,13 +1,14 @@ { pkgs, lib, config, inputs, ... }: { wayland.windowManager.hyprland = let colors = config.lib.stylix.colors; + accent = colors.${config.stylix.accent}; in { settings = { general = { gaps_in = 5; gaps_out = 5; border_size = 2; - "col.active_border" = "rgba(${colors.base0E}ee) rgba(${colors.base0C}ee) 45deg"; + "col.active_border" = "rgba(${accent}ee) rgba(${colors.base0C}ee) 45deg"; "col.inactive_border" = "rgba(${colors.base05}aa)"; layout = "dwindle"; diff --git a/user/chest/modules/style.nix b/user/chest/modules/style.nix index df13b72..afc7b8a 100644 --- a/user/chest/modules/style.nix +++ b/user/chest/modules/style.nix @@ -89,6 +89,7 @@ in { }; base16Scheme = "${pkgs.base16-schemes}/share/themes/eris.yaml"; + accent = "base0E"; polarity = "dark"; image = pkgs.fetchurl { diff --git a/user/chest/modules/waybar.nix b/user/chest/modules/waybar.nix index 7107935..31df24c 100644 --- a/user/chest/modules/waybar.nix +++ b/user/chest/modules/waybar.nix @@ -175,7 +175,7 @@ style = let colors = config.lib.stylix.colors.withHashtag; - accent = colors.base0E; + accent = colors.${config.stylix.accent}; scssFile = pkgs.writeText "waybar.scss" /*scss*/ '' window#waybar { background: transparent; diff --git a/user/sweetbread/modules/hyprland.nix b/user/sweetbread/modules/hyprland.nix index c3962c1..feca719 100644 --- a/user/sweetbread/modules/hyprland.nix +++ b/user/sweetbread/modules/hyprland.nix @@ -1,6 +1,7 @@ { pkgs, lib, config, osConfig, inputs, ... }: { wayland.windowManager.hyprland = let colors = config.lib.stylix.colors; + accent = colors.${config.stylix.accent}; wallpaper_changer = pkgs.writers.writePython3Bin "wallpaper_changer" { libraries = [ pkgs.python3Packages.requests ]; @@ -57,7 +58,7 @@ gaps_in = 2; gaps_out = 10; border_size = 3; - "col.active_border" = lib.mkForce "rgba(${colors.base0C}aa) rgba(${colors.base0B}aa) 45deg"; + "col.active_border" = lib.mkForce "rgba(${colors.base0C}aa) rgba(${accent}aa) 45deg"; layout = "dwindle"; }; diff --git a/user/sweetbread/modules/style.nix b/user/sweetbread/modules/style.nix index 93a238d..cbe3868 100644 --- a/user/sweetbread/modules/style.nix +++ b/user/sweetbread/modules/style.nix @@ -105,6 +105,7 @@ in { }; base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml"; + accent = "base0B"; polarity = "dark"; image = pkgs.fetchurl { diff --git a/user/sweetbread/modules/waybar.nix b/user/sweetbread/modules/waybar.nix index 457f728..3df9cbc 100644 --- a/user/sweetbread/modules/waybar.nix +++ b/user/sweetbread/modules/waybar.nix @@ -155,6 +155,7 @@ style = let colors = config.lib.stylix.colors.withHashtag; + accent = colors.${config.stylix.accent}; radius = "6px"; scssFile = pkgs.writeText "waybar.scss" /*scss*/ '' window#waybar { @@ -199,13 +200,13 @@ &:hover { background: ${colors.base01}; } &.active { - background: ${colors.base0B}; + background: ${accent}; color: ${colors.base00}; &:hover { - border-color: ${colors.base0B}; + border-color: ${accent}; background: ${colors.base01}; - color: ${colors.base0B}; + color: ${accent}; } } } @@ -259,7 +260,7 @@ #battery { &.plugged { color: ${colors.base0D}; } - &.charging { color: ${colors.base0B}; } + &.charging { color: ${accent}; } &:not(.charging) { &.warning { color: ${colors.base00}; @@ -277,7 +278,7 @@ } &.full { color: ${colors.base00}; - background: ${colors.base0B}; + background: ${accent}; } }