Flake : Abstract the style.

This commit is contained in:
Dmitry Voronin 2024-04-04 13:51:06 +03:00
parent 05de0d2b60
commit dd1b4ef71f
12 changed files with 154 additions and 62 deletions

109
flake.nix
View file

@ -109,13 +109,110 @@
};
# Styles.
style = { config , ... }: {
color_bg = config.lib.stylix.colors.base00;
color_fg = "000000";
style = { config, ... }: {
color = {
accent = config.lib.stylix.colors.base0A;
bg = config.lib.stylix.colors.base01;
bg_dark = config.lib.stylix.colors.base00;
bg_light = config.lib.stylix.colors.base07;
fg = config.lib.stylix.colors.base05;
fg_dark = config.lib.stylix.colors.base04;
fg_light = config.lib.stylix.colors.base06;
heading = config.lib.stylix.colors.base0D;
hl = config.lib.stylix.colors.base03;
keyword = config.lib.stylix.colors.base0E;
link = config.lib.stylix.colors.base09;
misc = config.lib.stylix.colors.base0F;
negative = config.lib.stylix.colors.base08;
neutral = config.lib.stylix.colors.base0C;
positive = config.lib.stylix.colors.base0B;
selection = config.lib.stylix.colors.base02;
transparent = "ffffff00";
accent-b = config.lib.stylix.colors.base0A-rgb-b;
accent-g = config.lib.stylix.colors.base0A-rgb-g;
accent-r = config.lib.stylix.colors.base0A-rgb-r;
negative-b = config.lib.stylix.colors.base08-rgb-b;
negative-g = config.lib.stylix.colors.base08-rgb-g;
negative-r = config.lib.stylix.colors.base08-rgb-r;
neutral-b = config.lib.stylix.colors.base0C-rgb-b;
neutral-g = config.lib.stylix.colors.base0C-rgb-g;
neutral-r = config.lib.stylix.colors.base0C-rgb-r;
positive-b = config.lib.stylix.colors.base0B-rgb-b;
positive-g = config.lib.stylix.colors.base0B-rgb-g;
positive-r = config.lib.stylix.colors.base0B-rgb-r;
};
font = {
emoji.name = config.stylix.fonts.emoji.name;
monospace.name = config.stylix.fonts.monospace.name;
sansSerif.name = config.stylix.fonts.sansSerif.name;
serif.name = config.stylix.fonts.serif.name;
size = {
terminal = config.stylix.fonts.sizes.terminal;
popup = config.stylix.fonts.sizes.popups;
application = config.stylix.fonts.sizes.applications;
desktop = config.stylix.fonts.sizes.desktop;
};
};
opacity = {
application = config.stylix.opacity.applications;
desktop = config.stylix.opacity.desktop;
popup = config.stylix.opacity.popups;
terminal = config.stylix.opacity.terminal;
};
};
defaultStyle = {
lib.stylix.colors = {
base00 = "ffffff";
accent = "b8bb26";
bg = "3c3836";
bg_dark = "1d2021";
bg_light = "504945";
fg = "ebdbb2";
fg_dark = "a89984";
fg_light = "fbf1c7";
heading = "d5c4a1";
hl = "98971a";
keyword = "98971a";
link = "076678";
misc = "808080";
negative = "cc241d";
neutral = "458588";
positive = "87af87";
selection = "87af87";
accent-b = "38";
accent-g = "187";
accent-r = "184";
negative-b = "29";
negative-g = "36";
negative-r = "204";
neutral-b = "136";
neutral-g = "133";
neutral-r = "69";
positive-b = "135";
positive-g = "175";
positive-r = "135";
};
stylix = {
fonts = {
monospace.name = "Terminess Nerd Font Mono";
emoji.name = "Noto Color Emoji";
sans.name = "SF Pro Display";
sansSerif.name = "SF Pro Display";
sizes = {
applications = 12;
terminal = 12;
popups = 12;
desktop = 12;
};
};
opacity = {
application = 1.0;
desktop = 1.0;
popup = 1.0;
terminal = 1.0;
};
};
};
@ -176,8 +273,8 @@
const = self.nixosModules.const;
flake = self;
inputs = inputs;
# style = self.style;
wallpaper = self.wallpaper { pkgs = nixpkgs.legacyPackages.${system}.pkgs; };
style = self.style { config = self.nixosConfigurations.${hostname}.config; };
wallpaper = self.wallpaper { pkgs = nixpkgs.legacyPackages.${system}.pkgs; };
};
};

View file

@ -1,5 +1,5 @@
{ pkgs, lib, wallpaper, config, ... }: let
sway = import ./sway/Config.nix { config = config; pkgs = pkgs; wallpaper = wallpaper; };
{ pkgs, lib, wallpaper, style, ... }: let
sway = import ./sway/Config.nix { pkgs = pkgs; wallpaper = wallpaper; style = style; };
in {
imports = [
./desktop/App.nix

View file

@ -1,5 +1,5 @@
{ lib, config, ... }: let
bash = import ./bash/Bash.nix { config = config; };
{ lib, style, ... }: let
bash = import ./bash/Bash.nix { style = style; };
in {
programs.bash.interactiveShellInit = bash.config;
environment.shellAliases = lib.mkForce {};

View file

@ -37,10 +37,5 @@
name = "Noto Color Emoji";
};
};
# targets = {
# foot = {
# enable = true;
# };
# };
};
}

View file

@ -1,23 +1,23 @@
{ config, ... }: let
negative-r = config.lib.stylix.colors.base08-rgb-r;
negative-g = config.lib.stylix.colors.base08-rgb-g;
negative-b = config.lib.stylix.colors.base08-rgb-b;
neutral-r = config.lib.stylix.colors.base0C-rgb-r;
neutral-g = config.lib.stylix.colors.base0C-rgb-g;
neutral-b = config.lib.stylix.colors.base0C-rgb-b;
positive-r = config.lib.stylix.colors.base0B-rgb-r;
positive-g = config.lib.stylix.colors.base0B-rgb-g;
positive-b = config.lib.stylix.colors.base0B-rgb-b;
accent-r = config.lib.stylix.colors.base0A-rgb-r;
accent-g = config.lib.stylix.colors.base0A-rgb-g;
accent-b = config.lib.stylix.colors.base0A-rgb-b;
{ style, ... }: let
accent-b = style.color.accent-b;
accent-g = style.color.accent-g;
accent-r = style.color.accent-r;
negative-b = style.color.negative-b;
negative-g = style.color.negative-g;
negative-r = style.color.negative-r;
neutral-b = style.color.neutral-b;
neutral-g = style.color.neutral-g;
neutral-r = style.color.neutral-r;
positive-b = style.color.positive-b;
positive-g = style.color.positive-g;
positive-r = style.color.positive-r;
bg = config.lib.stylix.colors.base01;
fg = config.lib.stylix.colors.base04;
accent = config.lib.stylix.colors.base06;
accent = style.color.accent;
bg = style.color.bg_dark;
fg = style.color.fg;
fontNamePopup = config.stylix.fonts.serif.name;
fontSizePopup = config.stylix.fonts.sizes.popups;
fontNamePopup = style.font.serif.name;
fontSizePopup = style.font.size.popup;
in {
config = ''
# If not running interactively, don't do anything.

View file

@ -1,10 +1,10 @@
{ pkgs, wallpaper, config, ... }: let
accent = config.lib.stylix.colors.base02;
bg = config.lib.stylix.colors.base00;
bg_alt = config.lib.stylix.colors.base01;
fg = config.lib.stylix.colors.base04;
fg_alt = config.lib.stylix.colors.base05;
negative = config.lib.stylix.colors.base03;
{ pkgs, wallpaper, style, ... }: let
accent = style.color.accent;
bg = style.color.bg_dark;
bg_alt = style.color.bg;
fg = style.color.fg;
fg_alt = style.color.fg_dark;
negative = style.color.negative;
in {
config = pkgs.writeText "sway_config" ''
# Read `man 5 sway` for a complete reference.

View file

@ -1,11 +1,11 @@
{ const, color, config, pkgs, ... }: {
{ const, color, style, pkgs, ... }: {
imports = [
(import ./Default.nix {
color = color;
config = config;
const = const;
homeDir = "/home/dasha";
pkgs = pkgs;
style = style;
username = "dasha";
})
];

View file

@ -1,6 +1,6 @@
{ const, username, homeDir, config, pkgs, ... }: let
footConfig = import ./module/foot/Foot.nix { config = config; };
makoConfig = import ./module/mako/Mako.nix { config = config; };
{ const, username, homeDir, style, pkgs, ... }: let
footConfig = import ./module/foot/Foot.nix { style = style; };
makoConfig = import ./module/mako/Mako.nix { style = style; };
in {
home-manager.backupFileExtension = "old";

View file

@ -1,11 +1,11 @@
{ const, color, pkgs, config, ... }: {
{ const, color, pkgs, style, ... }: {
imports = [
(import ./Default.nix {
color = color;
config = config;
const = const;
homeDir = "/root";
pkgs = pkgs;
style = style;
username = "root";
})
];

View file

@ -1,11 +1,11 @@
{ const, color, pkgs, config, ... }: {
{ const, color, pkgs, style, ... }: {
imports = [
(import ./Default.nix {
color = color;
config = config;
const = const;
homeDir = "/home/voronind";
pkgs = pkgs;
style = style;
username = "voronind";
})
];

View file

@ -1,14 +1,14 @@
{ config, ... }: {
{ style, ... }: {
config = ''
font=${config.stylix.fonts.monospace.name}:size=${toString(config.stylix.fonts.sizes.terminal)}
font-italic=${config.stylix.fonts.monospace.name}:size=${toString(config.stylix.fonts.sizes.terminal)}
# font-bold=${config.stylix.fonts.monospace.name}:size=${toString(config.stylix.fonts.sizes.terminal)}
font-bold-italic=${config.stylix.fonts.monospace.name}:size=${toString(config.stylix.fonts.sizes.terminal)}
font=${style.font.monospace.name}:size=${toString(style.font.size.terminal)}
# font-bold=${style.font.monospace.name}:size=${toString(style.font.size.terminal)}
font-italic=${style.font.monospace.name}:size=${toString(style.font.size.terminal)}
font-bold-italic=${style.font.monospace.name}:size=${toString(style.font.size.terminal)}
dpi-aware=yes
[colors]
alpha=${toString(config.stylix.opacity.terminal)}
background=${config.lib.stylix.colors.base00}
foreground=${config.lib.stylix.colors.base05}
alpha=${toString(style.opacity.terminal)}
background=${style.color.bg_dark}
foreground=${style.color.fg}
'';
}

View file

@ -1,10 +1,10 @@
{ config, ... }: {
{ style, ... }: {
config = ''anchor=top-center
default-timeout=5000
font=${config.stylix.fonts.serif.name} ${toString(config.stylix.fonts.sizes.popups)}
background-color=#${config.lib.stylix.colors.base01}
border-color=#${config.lib.stylix.colors.base01}
text-color=#${config.lib.stylix.colors.base05}
font=${style.font.serif.name} ${toString(style.font.size.popup)}
background-color=#${style.color.bg}
border-color=#${style.color.bg}
text-color=#${style.color.fg}
height=120
icons=0
margin=32