Moved theming modules
This commit is contained in:
1 parent
c6cd3018db
commit
a68f032fee
23 files changed
+22
-18
No files matched your search
@@ -1,5 +1,8 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [ ./custom/default.nix ];
|
||||
imports = [
|
||||
./custom/default.nix
|
||||
./theming/default.nix
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.theming;
|
||||
|
||||
# Font module type
|
||||
fontModule = types.submodule {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
description = "Font family name.";
|
||||
};
|
||||
package = mkOption {
|
||||
type = types.anything;
|
||||
description = "Font package";
|
||||
};
|
||||
recommendedSize = mkOption {
|
||||
type = types.nullOr types.int;
|
||||
default = null;
|
||||
description = "Recommended size for displaying this font.";
|
||||
};
|
||||
fallbackFonts = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "Fallback fonts for specified font.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
fontModules = [
|
||||
# Import all fonts
|
||||
./fonts/cozette-vector.nix
|
||||
./fonts/cozette.nix
|
||||
./fonts/dejavu-sans.nix
|
||||
./fonts/dejavu-serif.nix
|
||||
./fonts/dina.nix
|
||||
./fonts/fira-code.nix
|
||||
./fonts/nerd-fonts-symbols.nix
|
||||
./fonts/noto-color-emoji.nix
|
||||
./fonts/wqy-bitmapsong.nix
|
||||
./fonts/wqy-microhei-mono.nix
|
||||
./fonts/wqy-microhei.nix
|
||||
./fonts/wqy-zenhei-mono.nix
|
||||
./fonts/wqy-zenhei-sharp.nix
|
||||
./fonts/wqy-zenhei.nix
|
||||
];
|
||||
|
||||
# Gather enabled fonts.
|
||||
enabledFonts = [
|
||||
cfg.fonts.serif.name
|
||||
cfg.fonts.sansSerif.name
|
||||
cfg.fonts.monospace.name
|
||||
cfg.fonts.emoji.name
|
||||
] ++ map (font: font.name) cfg.fonts.extraFonts;
|
||||
|
||||
# Flatten dependencies of fonts
|
||||
fontPackages =
|
||||
converge
|
||||
(
|
||||
fonts:
|
||||
listToAttrs (
|
||||
map
|
||||
(font: {
|
||||
name = font;
|
||||
value = true;
|
||||
})
|
||||
(
|
||||
flatten (map (font: [ font.name ] ++ cfg.fonts.pkgs.${font.name}.fallbackFonts) (attrsToList fonts))
|
||||
)
|
||||
)
|
||||
)
|
||||
(
|
||||
listToAttrs (
|
||||
map (font: {
|
||||
name = font;
|
||||
value = true;
|
||||
}) enabledFonts
|
||||
)
|
||||
);
|
||||
|
||||
# Convert set of fonts to list of packages
|
||||
fontNameList = map (font: font.name) (attrsToList fontPackages);
|
||||
fontPackageList = map (font: cfg.fonts.pkgs.${font}.package) fontNameList;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
# Import all themes
|
||||
./themes/catppuccin.nix
|
||||
./themes/gruvbox.nix
|
||||
./themes/oxocarbon.nix
|
||||
./themes/papercolor.nix
|
||||
./themes/sakura.nix
|
||||
./themes/nord.nix
|
||||
];
|
||||
|
||||
options.desktop.theming =
|
||||
let
|
||||
colors = config.theming.schemeColors;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption "theming";
|
||||
|
||||
darkMode = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "Whether the app should use dark mode.";
|
||||
};
|
||||
|
||||
colorScheme = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Base 16 color scheme to use for styling. See stylix documentation for more information.";
|
||||
};
|
||||
|
||||
schemeColors = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = config.lib.stylix.colors;
|
||||
description = "Generated colors from scheme";
|
||||
};
|
||||
|
||||
colors = {
|
||||
bg = mkOption {
|
||||
type = types.str;
|
||||
default = colors.base00;
|
||||
};
|
||||
fg = mkOption {
|
||||
type = types.str;
|
||||
default = colors.base05;
|
||||
};
|
||||
bg-status = mkOption {
|
||||
type = types.str;
|
||||
default = colors.base01;
|
||||
};
|
||||
fg-status = mkOption {
|
||||
type = types.str;
|
||||
default = colors.base04;
|
||||
};
|
||||
bg-selection = mkOption {
|
||||
type = types.str;
|
||||
default = colors.base02;
|
||||
};
|
||||
bg-highlight = mkOption {
|
||||
type = types.str;
|
||||
default = colors.base03;
|
||||
};
|
||||
fg-search = mkOption {
|
||||
type = types.str;
|
||||
default = colors.base0A;
|
||||
};
|
||||
accent = mkOption {
|
||||
type = types.str;
|
||||
default = colors.base0E;
|
||||
};
|
||||
border-focused = mkOption {
|
||||
type = types.str;
|
||||
default = cfg.colors.fg;
|
||||
};
|
||||
border-unfocused = mkOption {
|
||||
type = types.str;
|
||||
default = cfg.colors.bg-selection;
|
||||
};
|
||||
};
|
||||
|
||||
colorsCSS = mkOption {
|
||||
type = types.lines;
|
||||
default =
|
||||
":root {\n"
|
||||
+ concatStrings (
|
||||
map (color: " --nix-color-${color.name}: #${color.value};\n") (attrsToList cfg.colors)
|
||||
)
|
||||
+ "}\n\n";
|
||||
description = "Colors as css variables";
|
||||
};
|
||||
|
||||
layout = {
|
||||
borderRadius = mkOption {
|
||||
type = types.int;
|
||||
default = 0;
|
||||
description = "Border radius of windows.";
|
||||
};
|
||||
|
||||
borderSize = mkOption {
|
||||
type = types.int;
|
||||
default = 1;
|
||||
description = "Size of borders used throughout UI.";
|
||||
};
|
||||
|
||||
windowPadding = mkOption {
|
||||
type = types.int;
|
||||
default = 2;
|
||||
description = "Margin of each window, actual space between windows will be twice this number.";
|
||||
};
|
||||
};
|
||||
|
||||
fonts = {
|
||||
pkgs = mkOption {
|
||||
type = types.attrsOf fontModule;
|
||||
default = builtins.listToAttrs (
|
||||
map (module: {
|
||||
name = module.name;
|
||||
value = module;
|
||||
}) (map (module: (import module) { inherit lib config pkgs; }) fontModules)
|
||||
);
|
||||
description = "All available font modules.";
|
||||
};
|
||||
|
||||
installed = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = fontNameList;
|
||||
description = "List of installed fonts.";
|
||||
};
|
||||
|
||||
serif = mkOption {
|
||||
type = fontModule;
|
||||
description = "Default serif font";
|
||||
};
|
||||
|
||||
sansSerif = mkOption {
|
||||
type = fontModule;
|
||||
description = "Default sansSerif font.";
|
||||
};
|
||||
|
||||
monospace = mkOption {
|
||||
type = fontModule;
|
||||
description = "Default monospace font.";
|
||||
};
|
||||
|
||||
emoji = mkOption {
|
||||
type = fontModule;
|
||||
description = "Default emoji font.";
|
||||
};
|
||||
|
||||
interface = mkOption {
|
||||
type = fontModule;
|
||||
description = "Default emoji font.";
|
||||
};
|
||||
|
||||
extraFonts = mkOption {
|
||||
type = types.listOf fontModule;
|
||||
default = [ ];
|
||||
description = "Additional fonts to install.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.modules.theming.enable {
|
||||
# Enable fontconfig
|
||||
modules.fontconfig.enable = true;
|
||||
|
||||
# Install configured fonts
|
||||
home.packages = fontPackageList;
|
||||
|
||||
# Configure gnome theme
|
||||
dconf.settings = {
|
||||
"org/gnome/desktop/interface" = {
|
||||
color-scheme = if cfg.darkMode then "prefer-dark" else "prefer-light";
|
||||
};
|
||||
};
|
||||
|
||||
# Configure qt theme
|
||||
qt = {
|
||||
enable = true;
|
||||
platformTheme.name = "adwaita";
|
||||
style.name = if cfg.darkMode then "adwaita-dark" else "adwaita-light";
|
||||
};
|
||||
|
||||
# Configure gtk theme
|
||||
gtk =
|
||||
# disableCSD = ''
|
||||
# headerbar.default-decoration {
|
||||
# margin-bottom: 50px;
|
||||
# margin-top: -100px;
|
||||
# }
|
||||
# window.csd,
|
||||
# window.csd decoration {
|
||||
# box-shadow: none;
|
||||
# }
|
||||
# '';
|
||||
{
|
||||
enable = true;
|
||||
|
||||
theme = {
|
||||
name = if cfg.darkMode then "Adwaita-dark" else "Adwaita-light";
|
||||
package = pkgs.gnome-themes-extra;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
# TODO: This should just straight up not be here
|
||||
programs.direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
};
|
||||
modules.git.ignores = [
|
||||
".direnv"
|
||||
];
|
||||
|
||||
# TODO: Make cursors configurable using modules.
|
||||
home.pointerCursor = {
|
||||
gtk.enable = true;
|
||||
name = lib.mkForce "BreezeX-RosePine-Linux";
|
||||
package = lib.mkForce pkgs.rose-pine-cursor;
|
||||
size = lib.mkForce 24;
|
||||
x11 = {
|
||||
defaultCursor = lib.mkForce "BreezeX-RosePine-Linux";
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Enable stylix
|
||||
# TODO: Move to own module
|
||||
stylix = {
|
||||
enable = true;
|
||||
autoEnable = false;
|
||||
|
||||
targets = {
|
||||
foot.enable = true;
|
||||
nixvim.enable = true;
|
||||
qutebrowser.enable = true;
|
||||
vscode.enable = true;
|
||||
zathura.enable = true;
|
||||
};
|
||||
|
||||
base16Scheme = cfg.colorScheme;
|
||||
polarity = if cfg.darkMode then "dark" else "light";
|
||||
|
||||
fonts = {
|
||||
serif = getAttrs [
|
||||
"name"
|
||||
"package"
|
||||
] cfg.fonts.serif;
|
||||
sansSerif = getAttrs [
|
||||
"name"
|
||||
"package"
|
||||
] cfg.fonts.sansSerif;
|
||||
monospace = getAttrs [
|
||||
"name"
|
||||
"package"
|
||||
] cfg.fonts.monospace;
|
||||
emoji = getAttrs [
|
||||
"name"
|
||||
"package"
|
||||
] cfg.fonts.emoji;
|
||||
|
||||
sizes = {
|
||||
applications = mkDefault cfg.fonts.serif.recommendedSize;
|
||||
desktop = mkDefault cfg.fonts.monospace.recommendedSize; # TODO: See below
|
||||
popups = mkDefault cfg.fonts.monospace.recommendedSize; # TODO: Add dedicated UI font
|
||||
terminal = mkDefault cfg.fonts.monospace.recommendedSize;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "Cozette Vector";
|
||||
package = pkgs.cozette;
|
||||
recommendedSize = 9;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "Cozette";
|
||||
package = pkgs.cozette;
|
||||
recommendedSize = 9;
|
||||
fallbackFonts = [ "Cozette Vector" ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "DejaVu Sans";
|
||||
package = pkgs.dejavu_fonts;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "DejaVu Serif";
|
||||
package = pkgs.dejavu_fonts;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "Dina";
|
||||
package = pkgs.dina-font;
|
||||
recommendedSize = 9;
|
||||
fallbackFonts = [
|
||||
"Cozette"
|
||||
"wenquanyi bitmap song"
|
||||
"Symbols Nerd Font Mono"
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "Fira Code";
|
||||
package = pkgs.fira-code;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ "Symbols Nerd Font Mono" ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "Symbols Nerd Font Mono";
|
||||
package = pkgs.nerd-fonts.symbols-only;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "Noto Color Emoji";
|
||||
package = pkgs.noto-fonts-color-emoji;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "wenquanyi bitmap song";
|
||||
package = pkgs.wqy-bitmapsong;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "WenQuanYi Micro Hei Mono";
|
||||
package = pkgs.wqy-microhei;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "WenQuanYi Micro Hei";
|
||||
package = pkgs.wqy-microhei;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "WenQuanYi Zen Hei Mono";
|
||||
package = pkgs.wqy-zenhei;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "WenQuanYi Zen Hei Sharp";
|
||||
package = pkgs.wqy-zenhei;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
name = "WenQuanYi Zen Hei";
|
||||
package = pkgs.wqy-zenhei;
|
||||
recommendedSize = 12;
|
||||
fallbackFonts = [ ];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.theming.themes.catppuccin;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
theming.themes.catppuccin = {
|
||||
enable = mkEnableOption "catppuccin";
|
||||
flavor = mkOption {
|
||||
type = types.enum [
|
||||
"latte"
|
||||
"frappe"
|
||||
"macchiato"
|
||||
"mocha"
|
||||
];
|
||||
default = "mocha";
|
||||
description = "The flavor of catppuccin theme.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config.theming = mkIf cfg.enable {
|
||||
darkMode = (cfg.flavor != "latte");
|
||||
colorScheme = "${pkgs.base16-schemes}/share/themes/catppuccin-${cfg.flavor}.yaml";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.theming.themes.gruvbox;
|
||||
mode = if cfg.darkMode then "dark" else "light";
|
||||
in
|
||||
{
|
||||
options = {
|
||||
theming.themes.gruvbox = {
|
||||
enable = mkEnableOption "gruvbox-hard";
|
||||
darkMode = mkEnableOption "dark mode";
|
||||
contrast = mkOption {
|
||||
type = types.enum [
|
||||
"hard"
|
||||
"medium"
|
||||
"soft"
|
||||
];
|
||||
default = "hard";
|
||||
description = "The contrast level of the theme.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config.theming = mkIf cfg.enable {
|
||||
darkMode = cfg.darkMode;
|
||||
colorScheme = "${pkgs.base16-schemes}/share/themes/gruvbox-${mode}-${cfg.contrast}.yaml";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.theming.themes.nord;
|
||||
mode = if cfg.darkMode then "" else "-light";
|
||||
in
|
||||
{
|
||||
options = {
|
||||
theming.themes.nord = {
|
||||
enable = mkEnableOption "nord";
|
||||
darkMode = mkEnableOption "dark mode";
|
||||
};
|
||||
};
|
||||
|
||||
config.theming = mkIf cfg.enable {
|
||||
darkMode = cfg.darkMode;
|
||||
colorScheme = "${pkgs.base16-schemes}/share/themes/nord${mode}.yaml";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.theming.themes.oxocarbon;
|
||||
mode = if cfg.darkMode then "dark" else "light";
|
||||
in
|
||||
{
|
||||
options = {
|
||||
theming.themes.oxocarbon = {
|
||||
enable = mkEnableOption "oxocarbon";
|
||||
darkMode = mkEnableOption "dark mode";
|
||||
};
|
||||
};
|
||||
|
||||
config.theming = mkIf cfg.enable {
|
||||
darkMode = cfg.darkMode;
|
||||
colorScheme = "${pkgs.base16-schemes}/share/themes/oxocarbon-${mode}.yaml";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.theming.themes.papercolor;
|
||||
mode = if cfg.darkMode then "dark" else "light";
|
||||
in
|
||||
{
|
||||
options = {
|
||||
theming.themes.papercolor = {
|
||||
enable = mkEnableOption "papercolor";
|
||||
darkMode = mkEnableOption "dark mode";
|
||||
};
|
||||
};
|
||||
|
||||
config.theming = mkIf cfg.enable {
|
||||
darkMode = cfg.darkMode;
|
||||
colorScheme = "${pkgs.base16-schemes}/share/themes/papercolor-${mode}.yaml";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.theming.themes.sakura;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
theming.themes.sakura = {
|
||||
enable = mkEnableOption "sakura";
|
||||
};
|
||||
};
|
||||
|
||||
config.theming = mkIf cfg.enable {
|
||||
darkMode = false;
|
||||
colorScheme = "${pkgs.base16-schemes}/share/themes/sakura.yaml";
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user