From e2e8971eb3b7c56c19fe37148dcdac806d331dc4 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 5 Apr 2024 13:28:23 -0400 Subject: [PATCH] chore: Simplify variable usage Changes made: - Preferred "inherits" where possible - Removed unnecessary comments - Added variables to avoid duplicate strings - Reduced usage of "with x;" --- home/dunst.nix | 7 +++-- home/eww.nix | 11 +++---- home/fcitx.nix | 71 +++++++++------------------------------------ home/gpg.nix | 7 +++-- home/gtk.nix | 7 +++-- home/ironbar.nix | 10 +++---- home/kitty.nix | 5 +++- home/mpv.nix | 5 +++- home/neovim.nix | 14 +++++---- modules/desktop.nix | 4 ++- 10 files changed, 60 insertions(+), 81 deletions(-) diff --git a/home/dunst.nix b/home/dunst.nix index b9b381e5..c7d1c819 100644 --- a/home/dunst.nix +++ b/home/dunst.nix @@ -1,13 +1,16 @@ { pkgs, ... }: +let + inherit (pkgs) libnotify papirus-icon-theme; +in { - home.packages = with pkgs; [ libnotify ]; + home.packages = [ libnotify ]; services.dunst = { enable = true; iconTheme = { - package = pkgs.papirus-icon-theme; + package = papirus-icon-theme; name = "Papirus"; }; diff --git a/home/eww.nix b/home/eww.nix index 754c83b9..436a0d58 100644 --- a/home/eww.nix +++ b/home/eww.nix @@ -2,6 +2,7 @@ let inherit (config.home) homeDirectory; + inherit (config.xdg.userDirs) download documents music pictures videos; in { home.packages = with pkgs; [ eww ]; @@ -10,11 +11,11 @@ in (defwidget icons [] (box :orientation "h" :spacing 32 (icon :img "default-user-home" :exec "${homeDirectory}") - (icon :img "default-folder-download" :exec "${homeDirectory}/ダウンロード") - (icon :img "default-folder-documents" :exec "${homeDirectory}/ドキュメント") - (icon :img "default-folder-music" :exec "${homeDirectory}/音楽") - (icon :img "default-folder-pictures" :exec "${homeDirectory}/画像") - (icon :img "default-folder-video" :exec "${homeDirectory}/ビデオ"))) + (icon :img "default-folder-download" :exec "${download}") + (icon :img "default-folder-documents" :exec "${documents}") + (icon :img "default-folder-music" :exec "${music}") + (icon :img "default-folder-pictures" :exec "${pictures}") + (icon :img "default-folder-video" :exec "${videos}"))) (defwidget icon [img exec] (eventbox :cursor "pointer" :onclick "lnch thunar ''${exec}" :tooltip "''${exec}" diff --git a/home/fcitx.nix b/home/fcitx.nix index 3776749c..5bb232ed 100644 --- a/home/fcitx.nix +++ b/home/fcitx.nix @@ -1,15 +1,21 @@ { config, ... }: +let + inherit (config.lib.stylix.colors) base01 base02 base05; + + font = "Noto Sans CJK JP 16"; + themeName = "base16"; +in { xdg.dataFile = { - "fcitx5/themes/base16/theme.conf".text = with config.lib.stylix.colors; /* ini */ '' + "fcitx5/themes/${themeName}/theme.conf".text = /* ini */ '' [Metadata] - Name=base16 + Name=${themeName} Version=0.1 ScaleWithDPI=True [InputPanel] - Font=Noto Sans CJK JP 16 + Font=${font} NormalColor=#${base05} HighlightCandidateColor=#${base05} HighlightColor=#${base05} @@ -104,23 +110,14 @@ force = true; text = /* ini */ '' [Hotkey] - # Enumerate when press trigger key repeatedly EnumerateWithTriggerKeys=True - # Temporally switch between first and current Input Method AltTriggerKeys= - # Enumerate Input Method Forward EnumerateForwardKeys= - # Enumerate Input Method Backward EnumerateBackwardKeys= - # Skip first input method while enumerating EnumerateSkipFirst=False - # Enumerate Input Method Group Forward EnumerateGroupForwardKeys= - # Enumerate Input Method Group Backward EnumerateGroupBackwardKeys= - # Activate Input Method ActivateKeys= - # Deactivate Input Method DeactivateKeys= [Hotkey/TriggerKeys] @@ -142,31 +139,18 @@ 0=Control+Alt+P [Behavior] - # Active By Default ActiveByDefault=False - # Share Input State ShareInputState=No - # Show preedit in application PreeditEnabledByDefault=True - # Show Input Method Information when switch input method ShowInputMethodInformation=True - # Show Input Method Information when changing focus showInputMethodInformationWhenFocusIn=False - # Show compact input method information CompactInputMethodInformation=True - # Show first input method information ShowFirstInputMethodInformation=True - # Default page size DefaultPageSize=5 - # Override Xkb Option OverrideXkbOption=False - # Custom Xkb Option CustomXkbOption= - # Force Enabled Addons EnabledAddons= - # Force Disabled Addons DisabledAddons= - # Preload input method to be used by default PreloadInputMethod=True ''; }; @@ -175,23 +159,16 @@ force = true; text = /* ini */ '' [Groups/0] - # Group Name Name="Group 1" - # Layout Default Layout=us - # Default Input Method DefaultIM=mozc [Groups/0/Items/0] - # Name Name=keyboard-us - # Layout Layout= [Groups/0/Items/1] - # Name Name=mozc - # Layout Layout= [GroupOrder] @@ -199,44 +176,29 @@ ''; }; - "fcitx5/conf/classicui.conf" = with config.lib.stylix.colors; { + "fcitx5/conf/classicui.conf" = { force = true; text = /* ini */ '' - # Vertical Candidate List Vertical Candidate List=False - # Use Per Screen DPI PerScreenDPI=True - # Use mouse wheel to go to prev or next page WheelForPaging=True - # Font - Font="Noto Sans CJK JP 16" - # Menu Font - MenuFont="Noto Sans CJK JP 16" - # Tray Font - TrayFont="Noto Sans CJK JP Medium 16" - # Tray Label Outline Color + Font="${font}" + MenuFont="${font}" + TrayFont="${font}" TrayOutlineColor=#${base02} - # Tray Label Text Color TrayTextColor=#${base05} - # Prefer Text Icon PreferTextIcon=False - # Show Layout Name In Icon ShowLayoutNameInIcon=True - # Use input method language to display text UseInputMethodLangaugeToDisplayText=True - # Theme - Theme=base16 + Theme=${themeName} ''; }; "fcitx5/conf/clipboard.conf" = { force = true; text = /* ini */ '' - # Trigger Key TriggerKey= - # Paste Primary PastePrimaryKey= - # Number of entries Number of entries=5 ''; }; @@ -244,15 +206,10 @@ "fcitx5/conf/mozc.conf" = { force = true; text = /* ini */ '' - # Initial Mode InitialMode=Hiragana - # Vertical candidate list Vertical=True - # Expand Usage (Requires vertical candidate list) ExpandMode="On Focus" - # Fix embedded preedit cursor at the beginning of the preedit PreeditCursorPositionAtBeginning=False - # Hotkey to expand usage ExpandKey=Control+Alt+H ''; }; diff --git a/home/gpg.nix b/home/gpg.nix index 7fb9c473..a270f3a3 100644 --- a/home/gpg.nix +++ b/home/gpg.nix @@ -1,9 +1,12 @@ { pkgs, ... }: +let + inherit (pkgs) pinentry-curses; +in { programs.gpg = { enable = true; - # homedir = "${config.xdg.dataHome}/gnupg" + settings = { personal-digest-preferences = "SHA512"; cert-digest-algo = "SHA512"; @@ -18,7 +21,7 @@ services.gpg-agent = { enable = true; - pinentryPackage = pkgs.pinentry-curses; + pinentryPackage = pinentry-curses; defaultCacheTtl = 43200; maxCacheTtl = 43200; }; diff --git a/home/gtk.nix b/home/gtk.nix index a1b04a81..432c2165 100644 --- a/home/gtk.nix +++ b/home/gtk.nix @@ -1,11 +1,14 @@ { pkgs, ... }: +let + inherit (pkgs) phinger-cursors fluent-icon-theme; +in { gtk = { enable = true; cursorTheme = { - package = pkgs.phinger-cursors; + package = phinger-cursors; name = "phinger-cursors"; }; @@ -19,7 +22,7 @@ }; iconTheme = { - package = pkgs.fluent-icon-theme; + package = fluent-icon-theme; name = "Fluent-dark"; }; }; diff --git a/home/ironbar.nix b/home/ironbar.nix index 96d00fd4..8ab3e98e 100644 --- a/home/ironbar.nix +++ b/home/ironbar.nix @@ -1,13 +1,13 @@ { config, lib, pkgs, ... }: let - inherit (builtins) attrValues toJSON; + inherit (builtins) toJSON; inherit (lib) singleton; + inherit (config.lib.stylix.colors) base00 base01 base04 base05 base09; + inherit (pkgs) ironbar; in { - home.packages = attrValues { - inherit (pkgs) ironbar; - }; + home.packages = [ ironbar ]; xdg.configFile."ironbar/config.json".text = toJSON { name = "main"; @@ -67,7 +67,7 @@ in ]; }; - xdg.configFile."ironbar/style.css".text = with config.lib.stylix.colors; /* css */ '' + xdg.configFile."ironbar/style.css".text = /* css */ '' * { font-family: "Noto Sans CJK JP", "Font Awesome 6 Free Solid"; font-size: 16px; diff --git a/home/kitty.nix b/home/kitty.nix index 4c4571fd..299c567c 100644 --- a/home/kitty.nix +++ b/home/kitty.nix @@ -1,5 +1,8 @@ { config, ... }: +let + inherit (config.lib.stylix.colors) base00; +in { programs.kitty = { enable = true; @@ -23,7 +26,7 @@ scrollback_pager = "less --chop-long-lines --raw-control-chars +INPUT_LINE_NUMBER"; }; - extraConfig = with config.lib.stylix.colors; '' + extraConfig = '' tab_bar_background #${base00} inactive_tab_background #${base00} map F1 send_text all \x1afg;notify-send "$(pwd)" "Task Completed."\r diff --git a/home/mpv.nix b/home/mpv.nix index 88a684ae..56bf67fc 100644 --- a/home/mpv.nix +++ b/home/mpv.nix @@ -1,5 +1,8 @@ { pkgs, ... }: +let + inherit (pkgs.mpvScripts) mpris uosc thumbfast; +in { programs.mpv = { enable = true; @@ -35,7 +38,7 @@ "ctrl+a" = "script-message osc-visibility cycle"; }; - scripts = with pkgs.mpvScripts; [ + scripts = [ mpris uosc thumbfast diff --git a/home/neovim.nix b/home/neovim.nix index 1f19813e..3701ad21 100644 --- a/home/neovim.nix +++ b/home/neovim.nix @@ -1,11 +1,15 @@ { pkgs, config, ... }: let - vim-nix-rummik = with pkgs.vimUtils; buildVimPlugin { - pname = "vim-nix"; - version = "0def8020f152a51c011a707680780dac61a8989a"; + inherit (pkgs) fetchFromGitHub; + inherit (pkgs.vimUtils) buildVimPlugin; + inherit (config.lib.stylix.scheme) slug; - src = pkgs.fetchFromGitHub { + vim-nix-rummik = buildVimPlugin { + pname = "vim-nix-rummik"; + version = "2022-11-16"; + + src = fetchFromGitHub { owner = "rummik"; repo = "vim-nix"; rev = "0def8020f152a51c011a707680780dac61a8989a"; @@ -406,7 +410,7 @@ in { plugin = base16-nvim; type = "lua"; - config = "vim.cmd('colorscheme base16-${config.lib.stylix.scheme.slug}')"; + config = "vim.cmd('colorscheme base16-${slug}')"; } { plugin = lualine-nvim; diff --git a/modules/desktop.nix b/modules/desktop.nix index 70d1314b..8509a49b 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -5,6 +5,7 @@ let inherit (config.modules.system) username; inherit (cfg) japanese bloat wine; inherit (builtins) attrValues; + inherit (nix-config.packages.${pkgs.system}) aleo-fonts; theme = "monokai"; opacity = 0.95; @@ -33,6 +34,7 @@ in thunar = { enable = true; + plugins = attrValues { inherit (pkgs.xfce) thunar-volman; }; @@ -169,7 +171,7 @@ in fonts = with pkgs; { serif = { - package = (callPackage ../packages/aleo-fonts.nix { }); + package = aleo-fonts; name = "Aleo"; };