2024-07-18 04:08:27 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
2024-07-18 14:29:20 +00:00
|
|
|
cfg = config.theming;
|
|
|
|
|
2024-07-18 04:08:27 +00:00
|
|
|
# Stylix
|
|
|
|
stylix = pkgs.fetchFromGitHub {
|
|
|
|
owner = "danth";
|
|
|
|
repo = "stylix";
|
|
|
|
rev = "1ff9d37d27377bfe8994c24a8d6c6c1734ffa116";
|
|
|
|
sha256 = "0dz8h1ga8lnfvvmvsf6iqvnbvxrvx3qxi0y8s8b72066mqgvy8y5";
|
|
|
|
};
|
2024-07-18 14:29:20 +00:00
|
|
|
|
|
|
|
# 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
|
2024-07-18 21:36:50 +00:00
|
|
|
./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
|
2024-07-18 14:29:20 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# 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
|
2024-07-18 20:21:06 +00:00
|
|
|
fontNameList = map (font: font.name) (attrsToList fontPackages);
|
|
|
|
fontPackageList = map (font: cfg.fonts.pkgs.${font}.package) fontNameList;
|
2024-07-18 04:08:27 +00:00
|
|
|
in {
|
|
|
|
imports = [
|
|
|
|
# Import all themes
|
|
|
|
./themes/gruvbox.nix
|
|
|
|
./themes/catppuccin.nix
|
|
|
|
];
|
|
|
|
|
2024-07-18 14:29:20 +00:00
|
|
|
options.modules.theming.enable = mkEnableOption "theming";
|
|
|
|
|
|
|
|
options.theming = let colors = config.theming.schemeColors; in {
|
2024-07-18 04:08:27 +00:00
|
|
|
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.";
|
|
|
|
};
|
|
|
|
|
2024-07-18 23:00:39 +00:00
|
|
|
clientSideDecorations = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable client side decorations for windows.";
|
|
|
|
};
|
|
|
|
|
2024-07-18 04:08:27 +00:00
|
|
|
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;
|
|
|
|
};
|
2024-07-18 22:36:02 +00:00
|
|
|
accent = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = colors.base09;
|
|
|
|
};
|
2024-07-18 16:13:19 +00:00
|
|
|
focused = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = cfg.colors.fg;
|
|
|
|
};
|
|
|
|
unfocused = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = colors.base02;
|
|
|
|
};
|
|
|
|
alert = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "ffffff"; # TODO: Derive color from theme
|
|
|
|
};
|
2024-07-18 04:08:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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.";
|
|
|
|
};
|
|
|
|
};
|
2024-07-18 14:29:20 +00:00
|
|
|
|
|
|
|
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.";
|
|
|
|
};
|
|
|
|
|
2024-07-18 20:21:06 +00:00
|
|
|
installed = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = fontNameList;
|
|
|
|
description = "List of installed fonts.";
|
|
|
|
};
|
|
|
|
|
2024-07-18 14:29:20 +00:00
|
|
|
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.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraFonts = mkOption {
|
|
|
|
type = types.listOf fontModule;
|
|
|
|
default = [];
|
|
|
|
description = "Additional fonts to install.";
|
|
|
|
};
|
|
|
|
};
|
2024-07-18 04:08:27 +00:00
|
|
|
};
|
|
|
|
|
2024-07-18 14:29:20 +00:00
|
|
|
config = mkIf config.modules.theming.enable {
|
|
|
|
# Enable fontconfig
|
|
|
|
modules.fontconfig.enable = true;
|
|
|
|
|
|
|
|
# Install configured fonts
|
|
|
|
home.packages = fontPackageList;
|
|
|
|
|
2024-07-18 23:00:39 +00:00
|
|
|
# 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 = let
|
|
|
|
disableCSD = ''
|
|
|
|
headerbar.default-decoration {
|
|
|
|
margin-bottom: 50px;
|
|
|
|
margin-top: -100px;
|
|
|
|
}
|
|
|
|
|
|
|
|
window.csd,
|
|
|
|
window.csd decoration {
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
theme = {
|
|
|
|
name = if cfg.darkMode then "Adwaita-dark" else "Adwaita-light";
|
|
|
|
package = pkgs.gnome-themes-extra;
|
|
|
|
};
|
|
|
|
|
2024-07-19 01:34:42 +00:00
|
|
|
gtk3.extraCss = mkIf (! cfg.clientSideDecorations) disableCSD;
|
|
|
|
gtk4.extraCss = mkIf (! cfg.clientSideDecorations) disableCSD;
|
|
|
|
};
|
|
|
|
|
|
|
|
# TODO: This should just straight up not be here
|
|
|
|
programs.direnv = {
|
|
|
|
enable = true;
|
|
|
|
nix-direnv.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
# 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;
|
|
|
|
};
|
|
|
|
};
|
2024-07-18 23:00:39 +00:00
|
|
|
|
2024-07-18 14:29:20 +00:00
|
|
|
# Enable stylix
|
|
|
|
# TODO: Move to own module
|
2024-07-18 04:08:27 +00:00
|
|
|
stylix = {
|
|
|
|
enable = true;
|
|
|
|
autoEnable = false;
|
|
|
|
|
2024-07-18 16:13:19 +00:00
|
|
|
targets = {
|
2024-07-19 01:34:42 +00:00
|
|
|
foot.enable = true;
|
|
|
|
nixvim.enable = true;
|
|
|
|
qutebrowser.enable = true;
|
|
|
|
vscode.enable = true;
|
|
|
|
zathura.enable = true;
|
2024-07-18 16:13:19 +00:00
|
|
|
};
|
|
|
|
|
2024-07-18 14:29:20 +00:00
|
|
|
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;
|
2024-07-18 16:13:19 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
2024-07-18 14:29:20 +00:00
|
|
|
};
|
2024-07-18 04:08:27 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|