home, modules: add myFlake.home-manager.colorScheme

This commit is contained in:
Guanran Wang 2023-11-23 14:05:54 +08:00
parent b07b91d6b6
commit 65a4e1e46a
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8
11 changed files with 207 additions and 162 deletions

View file

@ -0,0 +1,9 @@
{lib, ...}: {
options.myFlake.home-manager = {
colorScheme = lib.mkOption {
type = lib.types.enum [null "tokyonight"];
default = "tokyonight";
description = "Select desired terminal color scheme.";
};
};
}

View file

@ -1,5 +1,6 @@
{...}: { {...}: {
imports = [ imports = [
./terminal.nix ./terminal.nix
./color-scheme.nix
]; ];
} }

View file

@ -1,11 +1,4 @@
{ {lib, ...}: {
lib,
config,
pkgs,
...
}: let
cfg = config.myFlake.home-manager.terminal;
in {
# 3 terminals, one module. # 3 terminals, one module.
# -- The Orange Box (wtf) # -- The Orange Box (wtf)
@ -49,36 +42,6 @@ in {
example = 8; example = 8;
description = "Select desired terminal padding size (in px)."; description = "Select desired terminal padding size (in px).";
}; };
colorScheme = lib.mkOption {
type = lib.types.enum [null "tokyonight"];
default = "tokyonight";
description = "Select desired terminal color scheme.";
};
}; };
}; };
config.programs = lib.mkMerge [
{
alacritty.settings.cursor.style = cfg.cursorStyle;
kitty.settings.cursor_shape = cfg.cursorStyle;
foot.settings.cursor.style = cfg.cursorStyle;
alacritty.settings.font.size = cfg.fontSize;
kitty.settings.font_size = cfg.fontSize;
foot.settings.main.font = "monospace:size=${builtins.toString cfg.fontSize}";
alacritty.settings.window.padding.x = cfg.padding;
alacritty.settings.window.padding.y = cfg.padding;
kitty.settings.window_padding_width = builtins.toString (cfg.padding * (3.0 / 4.0)); # px -> pt
foot.settings.main.pad = "${builtins.toString cfg.padding}x${builtins.toString cfg.padding}";
}
# TODO: split this part to ./color-scheme.nix (???)
(lib.mkIf (cfg.colorScheme == "tokyonight") {
alacritty.settings.import = ["${pkgs.vimPlugins.tokyonight-nvim}/extras/alacritty/tokyonight_night.yml"];
kitty.settings.include = "${pkgs.vimPlugins.tokyonight-nvim}/extras/kitty/tokyonight_night.conf";
foot.settings.main.include = "${pkgs.vimPlugins.tokyonight-nvim}/extras/foot/tokyonight_night.ini";
})
];
} }

View file

@ -1,9 +1,15 @@
{...}: { {
config,
lib,
...
}: {
programs.helix = { programs.helix = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
settings = { settings = {
theme = "tokyonight"; theme =
lib.mkIf (config.myFlake.home-manager.colorScheme == "tokyonight")
"tokyonight";
editor = { editor = {
cursor-shape = { cursor-shape = {
insert = "bar"; insert = "bar";

View file

@ -1,71 +1,73 @@
{ {
lib, lib,
pkgs, pkgs,
config,
... ...
}: { }: {
programs.vscode = { programs.vscode = lib.mkMerge [
enable = true; {
package = pkgs.vscodium; # foss enable = true;
enableExtensionUpdateCheck = false; package = pkgs.vscodium; # foss
enableUpdateCheck = false; enableExtensionUpdateCheck = false;
keybindings = [ enableUpdateCheck = false;
{ keybindings = [
key = "tab"; {
command = "selectNextSuggestion"; key = "tab";
when = "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"; command = "selectNextSuggestion";
} when = "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion";
{ }
key = "shift+tab"; {
command = "selectPrevSuggestion"; key = "shift+tab";
when = "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion"; command = "selectPrevSuggestion";
} when = "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus || suggestWidgetVisible && textInputFocus && !suggestWidgetHasFocusedSuggestion";
]; }
userSettings = { ];
diffEditor.ignoreTrimWhitespace = false; userSettings = {
editor.cursorBlinking = "smooth"; diffEditor.ignoreTrimWhitespace = false;
editor.cursorSmoothCaretAnimation = "on"; editor.cursorBlinking = "smooth";
editor.fontFamily = lib.mkDefault "Monospace"; editor.cursorSmoothCaretAnimation = "on";
editor.fontWeight = 600; editor.fontFamily = lib.mkDefault "Monospace";
editor.smoothScrolling = true; editor.fontWeight = 600;
editor.tabSize = 2; editor.smoothScrolling = true;
explorer.confirmDragAndDrop = false; editor.tabSize = 2;
explorer.confirmDelete = false; explorer.confirmDragAndDrop = false;
files.autoSave = "onFocusChange"; explorer.confirmDelete = false;
files.trimTrailingWhitespace = true; files.autoSave = "onFocusChange";
files.trimFinalNewlines = true; files.trimTrailingWhitespace = true;
security.workspace.trust.enabled = false; files.trimFinalNewlines = true;
telemetry.telemetryLevel = "off"; security.workspace.trust.enabled = false;
terminal.integrated.cursorStyle = "line"; telemetry.telemetryLevel = "off";
terminal.integrated.smoothScrolling = true; terminal.integrated.cursorStyle = "line";
window.menuBarVisibility = "toggle"; terminal.integrated.smoothScrolling = true;
workbench.colorTheme = "Tokyo Night"; window.menuBarVisibility = "toggle";
workbench.list.smoothScrolling = true; workbench.list.smoothScrolling = true;
# Workaround for VSCode crashing # Workaround for VSCode crashing
# https://github.com/microsoft/vscode/issues/184124 # https://github.com/microsoft/vscode/issues/184124
window.titleBarStyle = "custom"; window.titleBarStyle = "custom";
workbench.layoutControl.enabled = false; workbench.layoutControl.enabled = false;
window.commandCenter = false; window.commandCenter = false;
# Language specific # Language specific
### Nix ### Nix
"[nix]".editor.tabSize = 2; "[nix]".editor.tabSize = 2;
# Extensions # Extensions
### GitLens ### GitLens
gitlens.telemetry.enabled = false; gitlens.telemetry.enabled = false;
}; };
extensions = with pkgs.vscode-extensions; [ extensions = with pkgs.vscode-extensions; [
### QoL ### QoL
eamodio.gitlens eamodio.gitlens
esbenp.prettier-vscode esbenp.prettier-vscode
ritwickdey.liveserver ritwickdey.liveserver
vscodevim.vim vscodevim.vim
];
}
### Themes (lib.mkIf (config.myFlake.home-manager.colorScheme == "tokyonight") {
enkia.tokyo-night extensions = [pkgs.vscode-extensions.enkia.tokyo-night];
#catppuccin.catppuccin-vsc-icons userSettings.workbench.colorTheme = "Tokyo Night";
#catppuccin.catppuccin-vsc })
]; ];
};
} }

View file

@ -1,9 +1,15 @@
{pkgs, ...}: { {
pkgs,
config,
lib,
...
}: {
programs.fish = { programs.fish = {
enable = true; enable = true;
interactiveShellInit = '' interactiveShellInit = ''
set fish_greeting set fish_greeting
source ${pkgs.vimPlugins.tokyonight-nvim}/extras/fish/tokyonight_night.fish ${lib.strings.optionalString (config.myFlake.home-manager.colorScheme == "tokyonight")
"source ${pkgs.vimPlugins.tokyonight-nvim}/extras/fish/tokyonight_night.fish"}
''; '';
plugins = [ plugins = [
{ {

View file

@ -1,6 +1,23 @@
{...}: { {
lib,
config,
pkgs,
...
}: let
cfg = config.myFlake.home-manager.terminal;
in {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
#settings.env.WINIT_X11_SCALE_FACTOR = "1"; # workaround for.. something? settings = {
import =
lib.mkIf (config.myFlake.home-manager.colorScheme == "tokyonight")
["${pkgs.vimPlugins.tokyonight-nvim}/extras/alacritty/tokyonight_night.yml"];
cursor.style = cfg.cursorStyle;
font.size = cfg.fontSize;
window.padding.x = cfg.padding;
window.padding.y = cfg.padding;
#env.WINIT_X11_SCALE_FACTOR = "1"; # workaround for.. something?
};
}; };
} }

View file

@ -1,5 +1,20 @@
{...}: { {
programs.foot = { lib,
config,
pkgs,
...
}: {
programs.foot = let
cfg = config.myFlake.home-manager.terminal;
in {
enable = true; enable = true;
settings = {
main.include =
lib.mkIf (config.myFlake.home-manager.colorScheme == "tokyonight")
"${pkgs.vimPlugins.tokyonight-nvim}/extras/foot/tokyonight_night.ini";
cursor.style = cfg.cursorStyle;
main.font = "monospace:size=${builtins.toString cfg.fontSize}";
main.pad = "${builtins.toString cfg.padding}x${builtins.toString cfg.padding}";
};
}; };
} }

View file

@ -1,6 +1,22 @@
{...}: { {
lib,
config,
pkgs,
...
}: let
cfg = config.myFlake.home-manager.terminal;
in {
programs.kitty = { programs.kitty = {
enable = true; enable = true;
settings.confirm_os_window_close = 0; settings = {
include =
lib.mkIf (config.myFlake.home-manager.colorScheme == "tokyonight")
"${pkgs.vimPlugins.tokyonight-nvim}/extras/kitty/tokyonight_night.conf";
cursor_shape = cfg.cursorStyle;
font_size = cfg.fontSize;
window_padding_width = builtins.toString (cfg.padding * (3.0 / 4.0)); # px -> pt
confirm_os_window_close = 0;
};
}; };
} }

View file

@ -1,27 +1,33 @@
{...}: { {
lib,
config,
...
}: {
services.dunst = { services.dunst = {
enable = true; enable = true;
settings = { settings = lib.mkMerge [
global = { {
padding = 10; global = {
horizontal_padding = 10; padding = 10;
frame_width = 2; horizontal_padding = 10;
font = "Monospace 10"; frame_width = 2;
icon_path = "/home/guanranwang/.local/share/icons/dunst"; font = "Monospace 10";
corner_radius = 10; icon_path = "/home/guanranwang/.local/share/icons/dunst";
corner_radius = 10;
max_icon_size = 128; # weird bug, default value (128) not working max_icon_size = 128; # weird bug, default value (128) not working
}; };
}
# Tokyonight (lib.mkIf (config.myFlake.home-manager.colorScheme == "tokyonight") {
global = { # Tokyonight
frame_color = "#c0caf5"; global = {
background = "#1a1b26"; frame_color = "#c0caf5";
foreground = "#c0caf5"; background = "#1a1b26";
}; foreground = "#c0caf5";
};
urgency_critical.frame_color = "#fab387"; urgency_critical.frame_color = "#fab387";
}; })
];
}; };
xdg.dataFile."icons/dunst" = { xdg.dataFile."icons/dunst" = {

View file

@ -1,6 +1,7 @@
{ {
pkgs, pkgs,
config, config,
lib,
... ...
}: { }: {
gtk.enable = true; gtk.enable = true;
@ -65,39 +66,42 @@
}; };
# Misc # Misc
xresources.properties = { xresources.properties = lib.mkMerge [
# Cursor {
"Xcursor.theme" = "Adwaita"; # Cursor
"Xcursor.theme" = "Adwaita";
# Fonts # Fonts
"Xft.autohint" = "0"; "Xft.autohint" = "0";
"Xft.lcdfilter" = "lcddefault"; "Xft.lcdfilter" = "lcddefault";
"Xft.hintstyle" = "hintslight"; "Xft.hintstyle" = "hintslight";
"Xft.hinting" = "1"; "Xft.hinting" = "1";
"Xft.antialias" = "1"; "Xft.antialias" = "1";
"Xft.rgba" = "rgb"; "Xft.rgba" = "rgb";
}
(lib.mkIf (config.myFlake.home-manager.colorScheme == "tokyonight") {
# Tokyonight color scheme
# i have no idea what does it apply to
"*background" = "#1a1b26";
"*foreground" = "#c0caf5";
# Tokyonight color scheme "*color0" = "#15161e";
# i have no idea what does it apply to "*color1" = "#f7768e";
"*background" = "#1a1b26"; "*color2" = "#9ece6a";
"*foreground" = "#c0caf5"; "*color3" = "#e0af68";
"*color4" = "#7aa2f7";
"*color5" = "#bb9af7";
"*color6" = "#7dcfff";
"*color7" = "#a9b1d6";
"*color0" = "#15161e"; "*color8" = "#414868";
"*color1" = "#f7768e"; "*color9" = "#f7768e";
"*color2" = "#9ece6a"; "*color10" = "#9ece6a";
"*color3" = "#e0af68"; "*color11" = "#e0af68";
"*color4" = "#7aa2f7"; "*color12" = "#7aa2f7";
"*color5" = "#bb9af7"; "*color13" = "#bb9af7";
"*color6" = "#7dcfff"; "*color14" = "#7dcfff";
"*color7" = "#a9b1d6"; "*color15" = "#c0caf5";
})
"*color8" = "#414868"; ];
"*color9" = "#f7768e";
"*color10" = "#9ece6a";
"*color11" = "#e0af68";
"*color12" = "#7aa2f7";
"*color13" = "#bb9af7";
"*color14" = "#7dcfff";
"*color15" = "#c0caf5";
};
} }