treewide: remove use of multiple with statements (#1085)

This commit is contained in:
awwpotato 2025-04-08 15:22:18 -07:00 committed by GitHub
parent a2f8840bed
commit c8bc1c1d9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 161 additions and 155 deletions

View file

@ -21,7 +21,7 @@ in
};
size = sizes.terminal;
};
window.opacity = with config.stylix.opacity; terminal;
window.opacity = config.stylix.opacity.terminal;
colors = with colors; {
primary = {
foreground = base05;

View file

@ -25,9 +25,8 @@
{
programs.bemenu.settings =
with config.lib.stylix.colors.withHashtag;
with config.stylix.fonts;
with config.stylix.targets.bemenu;
let
inherit (config.stylix.targets.bemenu) alternate fontSize;
bemenuOpacity = lib.toHexString (
((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100
);
@ -51,7 +50,7 @@
af = "${if alternate then base04 else base05}"; # Alternate fg
# Font name
fn = "${sansSerif.name} ${
fn = "${config.stylix.fonts.sansSerif.name} ${
lib.optionalString (fontSize != null) (builtins.toString fontSize)
}";
};

View file

@ -1,37 +1,40 @@
{ config, lib, ... }:
let
dunstOpacity = lib.toHexString (
((builtins.floor (config.stylix.opacity.popups * 100 + 0.5)) * 255) / 100
);
in
{
options.stylix.targets.dunst.enable =
config.lib.stylix.mkEnableTarget "Dunst" true;
config = lib.mkIf (config.stylix.enable && config.stylix.targets.dunst.enable) {
services.dunst.settings = with config.lib.stylix.colors.withHashtag; {
global = {
separator_color = base02;
font = with config.stylix.fonts; "${sansSerif.name} ${toString sizes.popups}";
};
services.dunst.settings =
with config.lib.stylix.colors.withHashtag;
let
inherit (config.stylix) fonts;
dunstOpacity = lib.toHexString (
((builtins.floor (config.stylix.opacity.popups * 100 + 0.5)) * 255) / 100
);
in
{
global = {
separator_color = base02;
font = "${fonts.sansSerif.name} ${toString fonts.sizes.popups}";
};
urgency_low = {
background = base01 + dunstOpacity;
foreground = base05;
frame_color = base0B;
};
urgency_low = {
background = base01 + dunstOpacity;
foreground = base05;
frame_color = base0B;
};
urgency_normal = {
background = base01 + dunstOpacity;
foreground = base05;
frame_color = base0E;
};
urgency_normal = {
background = base01 + dunstOpacity;
foreground = base05;
frame_color = base0E;
};
urgency_critical = {
background = base01 + dunstOpacity;
foreground = base05;
frame_color = base08;
urgency_critical = {
background = base01 + dunstOpacity;
foreground = base05;
frame_color = base08;
};
};
};
};
}

View file

@ -26,32 +26,32 @@
themes.stylix =
let
inherit (config.lib.stylix) colors;
inherit (config.lib.stylix.colors) withHashtag;
in
{
palette = [
"0=${withHashtag.base00}"
"1=${withHashtag.base08}"
"2=${withHashtag.base0B}"
"3=${withHashtag.base0A}"
"4=${withHashtag.base0D}"
"5=${withHashtag.base0E}"
"6=${withHashtag.base0C}"
"7=${withHashtag.base05}"
"8=${withHashtag.base03}"
"9=${withHashtag.base08}"
"10=${withHashtag.base0B}"
"11=${withHashtag.base0A}"
"12=${withHashtag.base0D}"
"13=${withHashtag.base0E}"
"14=${withHashtag.base0C}"
"15=${withHashtag.base07}"
];
background = colors.base00;
foreground = colors.base05;
cursor-color = colors.base05;
selection-background = colors.base02;
selection-foreground = colors.base05;
palette = with colors.withHashtag; [
"0=${base00}"
"1=${base08}"
"2=${base0B}"
"3=${base0A}"
"4=${base0D}"
"5=${base0E}"
"6=${base0C}"
"7=${base05}"
"8=${base03}"
"9=${base08}"
"10=${base0B}"
"11=${base0A}"
"12=${base0D}"
"13=${base0E}"
"14=${base0C}"
"15=${base07}"
];
};
};
};

View file

@ -8,6 +8,7 @@
let
cfg = config.stylix.targets.grub;
inherit (config.stylix) imageScalingMode fonts;
inherit (config.lib.stylix) mkEnableTarget mkEnableWallpaper pixel;
# Grub requires fonts to be converted to "PFF2 format"
# This function takes a font { name, package } and produces a .pf2 file
mkGrubFont =
@ -57,15 +58,13 @@ in
];
})
];
options.stylix.targets.grub = with config.lib.stylix; {
options.stylix.targets.grub = {
enable = mkEnableTarget "GRUB" true;
useWallpaper = mkEnableWallpaper "GRUB" false;
};
config.boot.loader.grub =
with config.lib.stylix.colors.withHashtag;
with config.lib.stylix;
with config.stylix.fonts;
lib.mkIf (config.stylix.enable && cfg.enable) {
backgroundColor = base00;
# Need to override the NixOS splash, this will match the background
@ -144,7 +143,7 @@ in
cp ${pixel "base01"} $out/background_c.png
cp ${pixel "base0B"} $out/selection_c.png
cp ${mkGrubFont sansSerif} $out/sans_serif.pf2
cp ${mkGrubFont fonts.sansSerif} $out/sans_serif.pf2
'';
};
}

View file

@ -27,9 +27,7 @@ in
inherit (config.stylix.fonts.monospace) package name;
size = config.stylix.fonts.sizes.terminal;
};
settings.background_opacity =
with config.stylix.opacity;
"${builtins.toString terminal}";
settings.background_opacity = "${builtins.toString config.stylix.opacity.terminal}";
extraConfig = ''
include ${theme}
'';

View file

@ -3,9 +3,6 @@
lib,
...
}:
let
colors = config.lib.stylix.colors.withHashtag;
in
{
options.stylix.targets.lazygit.enable =
config.lib.stylix.mkEnableTarget "lazygit" true;
@ -13,22 +10,23 @@ in
config =
lib.mkIf (config.stylix.enable && config.stylix.targets.lazygit.enable)
{
programs.lazygit.settings.gui.theme = {
activeBorderColor = [
colors.base07
"bold"
];
inactiveBorderColor = [ colors.base04 ];
searchingActiveBorderColor = [
colors.base02
"bold"
];
optionsTextColor = [ colors.base06 ];
selectedLineBgColor = [ colors.base03 ];
cherryPickedCommitBgColor = [ colors.base02 ];
cherryPickedCommitFgColor = [ colors.base03 ];
unstagedChangesColor = [ colors.base08 ];
defaultFgColor = [ colors.base05 ];
};
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 ];
};
};
}

View file

@ -4,11 +4,6 @@
options,
...
}:
let
makoOpacity = lib.toHexString (
((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100
);
in
{
options.stylix.targets.mako.enable =
config.lib.stylix.mkEnableTarget "Mako" true;
@ -17,14 +12,19 @@ in
config = lib.optionalAttrs (options.services ? mako) (
lib.mkIf (config.stylix.enable && config.stylix.targets.mako.enable) {
services.mako =
let
makoOpacity = lib.toHexString (
((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100
);
inherit (config.stylix) fonts;
in
with config.lib.stylix.colors.withHashtag;
with config.stylix.fonts;
{
backgroundColor = base00 + makoOpacity;
borderColor = base0D;
textColor = base05;
progressColor = "over ${base02}";
font = "${sansSerif.name} ${toString sizes.popups}";
font = "${fonts.sansSerif.name} ${toString fonts.sizes.popups}";
# I wish the mako hm module was like the dunst one
extraConfig = ''
[urgency=low]

View file

@ -1,7 +1,4 @@
{ config, lib, ... }:
let
inherit (config.stylix) fonts opacity;
in
{
options.stylix.targets.mangohud.enable =
config.lib.stylix.mkEnableTarget "mangohud" true;
@ -9,31 +6,36 @@ in
config =
lib.mkIf (config.stylix.enable && config.stylix.targets.mangohud.enable)
{
programs.mangohud.settings = with config.lib.stylix.colors; {
font_size = fonts.sizes.applications;
font_size_text = fonts.sizes.applications;
background_alpha = opacity.popups;
alpha = opacity.applications;
text_color = base05;
text_outline_color = base00;
background_color = base00;
gpu_color = base0B;
cpu_color = base0D;
vram_color = base0C;
media_player_color = base05;
engine_color = base0E;
wine_color = base0E;
frametime_color = base0B;
battery_color = base04;
io_color = base0A;
gpu_load_color = "${base0B}, ${base0A}, ${base08}";
cpu_load_color = "${base0B}, ${base0A}, ${base08}";
fps_color = "${base0B}, ${base0A}, ${base08}";
programs.mangohud.settings =
let
inherit (config.stylix) fonts opacity;
in
with config.lib.stylix.colors;
{
font_size = fonts.sizes.applications;
font_size_text = fonts.sizes.applications;
background_alpha = opacity.popups;
alpha = opacity.applications;
text_color = base05;
text_outline_color = base00;
background_color = base00;
gpu_color = base0B;
cpu_color = base0D;
vram_color = base0C;
media_player_color = base05;
engine_color = base0E;
wine_color = base0E;
frametime_color = base0B;
battery_color = base04;
io_color = base0A;
gpu_load_color = "${base0B}, ${base0A}, ${base08}";
cpu_load_color = "${base0B}, ${base0A}, ${base08}";
fps_color = "${base0B}, ${base0A}, ${base08}";
# TODO: Use the point unit:
# https://github.com/danth/stylix/issues/251.
font_scale = 1.33333;
};
# TODO: Use the point unit:
# https://github.com/danth/stylix/issues/251.
font_scale = 1.33333;
};
};
}

View file

@ -16,7 +16,7 @@
# converting font size to px
size = sizes.terminal * 4.0 / 3.0;
};
window.opacity = with config.stylix.opacity; terminal;
window.opacity = config.stylix.opacity.terminal;
colors = with config.lib.stylix.colors.withHashtag; {
selection-background = base02;
selection-foreground = base05;

View file

@ -12,7 +12,9 @@
lib.mkIf (config.stylix.enable && config.stylix.targets.swaync.enable)
{
services.swaync.style =
with config.stylix.fonts;
let
inherit (config.stylix) fonts;
in
with config.lib.stylix.colors.withHashtag;
''
@define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03};
@ -22,8 +24,8 @@
@define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F};
* {
font-family: "${sansSerif.name}";
font-size: ${builtins.toString sizes.desktop}pt;
font-family: "${fonts.sansSerif.name}";
font-size: ${builtins.toString fonts.sizes.desktop}pt;
}
''
+ (builtins.readFile ./base.css);

View file

@ -1,20 +1,18 @@
{ config, lib, ... }:
let
inherit (config.lib.stylix) colors;
inherit (config.stylix) fonts;
in
{
options.stylix.targets.sxiv.enable =
config.lib.stylix.mkEnableTarget "Sxiv" true;
config = lib.mkIf (config.stylix.enable && config.stylix.targets.sxiv.enable) {
xresources = {
properties = {
xresources.properties =
let
inherit (config.lib.stylix) colors;
inherit (config.stylix) fonts;
in
{
"Sxiv.foreground" = "#${colors.base01}";
"Sxiv.background" = "#${colors.base04}";
"Sxiv.font" = "${fonts.sansSerif.name}-${toString fonts.sizes.applications}";
};
};
};
}

View file

@ -9,9 +9,9 @@
config = lib.mkIf (config.stylix.enable && config.stylix.targets.tofi.enable) {
programs.tofi.settings =
with config.stylix.fonts;
with config.lib.stylix.colors.withHashtag;
let
inherit (config.stylix) fonts;
opacity = lib.toHexString (
((builtins.ceil (config.stylix.opacity.popups * 100)) * 255) / 100
);
@ -21,8 +21,8 @@
selection = base03 + opacity;
in
{
font = monospace.name;
font-size = toString sizes.popups;
font = fonts.monospace.name;
font-size = toString fonts.sizes.popups;
background-color = background;
outline-color = darkForeground;
border-color = foreground;

View file

@ -70,7 +70,9 @@
};
xdg.configFile."wezterm/wezterm.lua".text =
with config.stylix.fonts;
let
inherit (config.stylix) fonts;
in
lib.mkForce ''
-- Generated by Stylix
local wezterm = require("wezterm")
@ -83,10 +85,10 @@
stylix_base_config = {
color_scheme = "stylix",
font = wezterm.font_with_fallback {
"${monospace.name}",
"${emoji.name}",
"${fonts.monospace.name}",
"${fonts.emoji.name}",
},
font_size = ${builtins.toString sizes.terminal},
font_size = ${builtins.toString fonts.sizes.terminal},
window_background_opacity = ${builtins.toString config.stylix.opacity.terminal},
window_frame = {
active_titlebar_bg = "${base03}",
@ -132,7 +134,7 @@
},
command_palette_bg_color = "${base01}",
command_palette_fg_color = "${base05}",
command_palette_font_size = ${builtins.toString sizes.popups},
command_palette_font_size = ${builtins.toString fonts.sizes.popups},
}
for key, value in pairs(stylix_user_config) do
stylix_base_config[key] = value

View file

@ -5,13 +5,13 @@
config = lib.mkIf (config.stylix.enable && config.stylix.targets.wob.enable) {
services.wob.settings = {
"" = {
border_color = config.lib.stylix.colors.base05;
background_color = config.lib.stylix.colors.base00;
bar_color = config.lib.stylix.colors.base0A;
overflow_bar_color = config.lib.stylix.colors.base08;
overflow_background_color = config.lib.stylix.colors.base00;
overflow_border_color = config.lib.stylix.colors.base05;
"" = with config.lib.stylix.colors; {
border_color = base05;
background_color = base00;
bar_color = base0A;
overflow_bar_color = base08;
overflow_background_color = base00;
overflow_border_color = base05;
};
};
};

View file

@ -9,12 +9,14 @@
config = lib.mkIf (config.stylix.enable && config.stylix.targets.wofi.enable) {
programs.wofi.style =
let
inherit (config.stylix) fonts;
in
with config.lib.stylix.colors.withHashtag;
with config.stylix.fonts;
''
window {
font-family: "${monospace.name}";
font-size: ${toString sizes.popups}pt;
font-family: "${fonts.monospace.name}";
font-size: ${toString fonts.sizes.popups}pt;
background-color: ${base00};
color: ${base05};

View file

@ -8,11 +8,13 @@
lib.mkIf (config.stylix.enable && config.stylix.targets.xresources.enable)
{
xresources.properties =
let
inherit (config.stylix) fonts;
in
with config.lib.stylix.colors.withHashtag;
with config.stylix.fonts;
{
"*.faceName" = monospace.name;
"*.faceSize" = toString sizes.terminal;
"*.faceName" = fonts.monospace.name;
"*.faceSize" = toString fonts.sizes.terminal;
"*.renderFont" = true;
"*foreground" = base05;
"*background" = base00;

View file

@ -3,11 +3,6 @@
lib,
...
}:
let
theme = config.lib.stylix.colors {
templateRepo = config.stylix.inputs.tinted-zed;
};
in
{
options.stylix.targets.zed.enable = config.lib.stylix.mkEnableTarget "zed" true;
@ -19,14 +14,20 @@ in
&& config.programs.zed-editor.enable
)
{
programs.zed-editor.userSettings = {
"buffer_font_family" = config.stylix.fonts.monospace.name;
"buffer_font_size" = config.stylix.fonts.sizes.terminal * 4.0 / 3.0;
"theme" = "Base16 ${config.lib.stylix.colors.scheme-name}";
"ui_font_family" = config.stylix.fonts.sansSerif.name;
"ui_font_size" = config.stylix.fonts.sizes.applications * 4.0 / 3.0;
};
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;
};
xdg.configFile."zed/themes/nix.json".source = theme;
xdg.configFile."zed/themes/nix.json".source = config.lib.stylix.colors {
templateRepo = config.stylix.inputs.tinted-zed;
};
};
}