From d134f0758e550615eadb6acb681778a7a0dbadbf Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Wed, 26 Feb 2025 21:06:09 -0800 Subject: [PATCH] home: add kde keyboard layouts, fish, starship config --- home/default.nix | 97 ++++++++++++++++++++++++++++++++++++++- modules/mods/kb-input.nix | 18 ++++++-- 2 files changed, 109 insertions(+), 6 deletions(-) diff --git a/home/default.nix b/home/default.nix index ca1ccb2..866f284 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ config, lib, pkgs, ... }: let defaultFont = { family = "Noto Sans"; @@ -38,6 +38,90 @@ in }; }; + programs.fish = { + enable = true; + shellInit = "set fish_greeting"; + shellAliases = { + # Replace ls with exa + ls = "exa -al --color=always --group-directories-first --icons"; # preferred listing + la = "exa -a --color=always --group-directories-first --icons"; # all files and dirs + ll = "exa -l --color=always --group-directories-first --icons"; # long format + lt = "exa -aT --color=always --group-directories-first --icons"; # tree listing + "l." = "exa -a | rg '^\.'"; # show only dotfiles + + # Replace cat with bat + cat = "bat"; + }; + # alias for nix shell with flake packages + functions.add.body = '' + set -x packages 'nixpkgs#'(string join ' nixpkgs#' $argv) + nix shell $packages --command fish + ''; + interactiveShellInit = '' + fastfetch + ''; + }; + + programs.starship = { + enable = true; + enableFishIntegration = true; + settings = { + format = lib.concatStrings [ + "$all" + "$time" + "$cmd_duration" + "$line_break" + "$jobs" + "$status" + "$character" + ]; + username = { + format = " [╭─$user]($style)@"; + style_user = "bold red"; + style_root = "bold red"; + show_always = true; + }; + hostname = { + format = "[$hostname]($style) in "; + style = "bold dimmed red"; + ssh_only = false; + }; + directory = { + style = "purple"; + truncation_length = 0; + truncate_to_repo = true; + truncation_symbol = "repo: "; + }; + git_status = { + style = "white"; + ahead = "⇡\${count}"; + diverged = "⇕⇡\${ahead_count}⇣\${behind_count}"; + behind = "⇣\${count}"; + deleted = "x"; + }; + cmd_duration = { + min_time = 1000; + format = "took [$duration]($style) "; + }; + time = { + format = " 🕙 $time($style) "; + time_format = "%T"; + style = "bright-white"; + disabled = false; + }; + character = { + success_symbol = " [╰─λ](bold red)"; + error_symbol = " [×](bold red)"; + }; + status = { + symbol = "🔴"; + format = "[\\[$symbol$status_common_meaning$status_signal_name$status_maybe_int\\]]($style)"; + map_symbol = true; + disabled = false; + }; + }; + }; + programs.plasma = { enable = true; overrideConfig = true; @@ -50,7 +134,11 @@ in menu = defaultFont; windowTitle = defaultFont; }; - input.keyboard.layouts = [ { layout = "minimak-4"; displayName = "us4"; } ]; + input.keyboard.layouts = [ + { layout = "us"; displayName = "us"; } + { layout = "minimak-4"; displayName = "us4"; } + { layout = "ru"; displayName = "ru"; } + ]; kwin.virtualDesktops.number = 2; session.sessionRestore.restoreOpenApplicationsOnLogin = "startWithEmptySession"; shortcuts = { @@ -58,6 +146,7 @@ in kmix.mic_mute = ["Microphone Mute" "ScrollLock" "Meta+Volume Mute,Microphone Mute" "Meta+Volume Mute,Mute Microphone"]; plasmashell.show-barcode = "Meta+M"; kwin."Window Maximize" = [ "Meta+F" "Meta+PgUp,Maximize Window" ]; + "KDE Keyboard Layout Switcher"."Switch to Next Keyboard Layout" = "Meta+Space"; }; hotkeys.commands."launch-konsole" = { name = "Launch Konsole"; @@ -81,6 +170,10 @@ in }; }; + xdg.configFile = { + "fcitx5/conf/wayland.conf".text = "Allow Overriding System XKB Settings=False"; + }; + # This value determines the Home Manager release that your configuration is # compatible with. This helps avoid breakage when a new Home Manager release # introduces backwards incompatible changes. diff --git a/modules/mods/kb-input.nix b/modules/mods/kb-input.nix index 8505e1a..9174118 100644 --- a/modules/mods/kb-input.nix +++ b/modules/mods/kb-input.nix @@ -9,11 +9,21 @@ in { options = { mods.kb-input = { enable = lib.mkEnableOption "input method and custom keyboard layout"; + enableMinimak = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable Minimak keyboard layout"; + }; + enableFcitx = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable Fcitx5 input method"; + }; }; }; config = lib.mkIf cfg.enable { - services.xserver.xkb.extraLayouts = { + services.xserver.xkb.extraLayouts = lib.mkIf cfg.enableMinimak { minimak-4 = { description = "English (US, Minimak-4)"; languages = [ "eng" ]; @@ -31,12 +41,12 @@ in { }; }; - i18n.inputMethod = { - type = "fcitx5"; + i18n.inputMethod = lib.mkIf cfg.enableFcitx { enable = true; + type = "fcitx5"; fcitx5.waylandFrontend = true; fcitx5.plasma6Support = true; fcitx5.addons = [ pkgs.fcitx5-mozc ]; }; }; -} \ No newline at end of file +}