From 8dc79f60ee96eb3bff23671f06a3e1ca82867c53 Mon Sep 17 00:00:00 2001 From: voidarc Date: Thu, 27 Aug 2026 14:21:49 +0100 Subject: [PATCH] formatted zsh and replaced manual flakeLocation with universal --- modules/features/zsh/default.nix | 150 +++++++++++++++---------------- 1 file changed, 74 insertions(+), 76 deletions(-) diff --git a/modules/features/zsh/default.nix b/modules/features/zsh/default.nix index 0f7cf7c..d8cf932 100644 --- a/modules/features/zsh/default.nix +++ b/modules/features/zsh/default.nix @@ -25,87 +25,85 @@ }); perSystem = { pkgs, - lib, self', + lib, + flakeLocation, ... }: { packages = { - zsh = let - flakeLocation = builtins.getEnv "PWD"; - in - lib.warnIf (flakeLocation == "") "Flake Location is undefined. Are you building in the right directory?" - inputs.wrappers.wrappers.zsh.wrap { - inherit pkgs; - runtimePkgs = [pkgs.carapace pkgs.devenv pkgs.fzf]; - zshAliases = { - ls = "${lib.getExe pkgs.lsd} -l"; - v = lib.getExe self'.packages.nvim; - cat = lib.getExe pkgs.bat; - lg = lib.getExe pkgs.lazygit; - man = "man -P \"${lib.getExe pkgs.bat} -p\""; - nsh = "nix-shell -p"; - nrs = - if flakeLocation != "" - then "( cd ${flakeLocation} && sudo nixos-rebuild switch --impure --flake . )" - else "echo 'Flake location not specified. Did you build with --impure?'"; - vinix = - if flakeLocation != "" - then "nvim --cmd 'cd ${flakeLocation}'" - else "echo 'Flake location not specified. Did you build with --impure?'"; - }; - zshrc.content = '' - source ${./devenv.zsh} - - if (( ''${+terminfo[smkx]} )) && (( ''${+terminfo[rmkx]} )); then - function zle-line-init() { echoti smkx } - function zle-line-finish() { echoti rmkx } - zle -N zle-line-init - zle -N zle-line-finish - fi - - autoload -U compinit && compinit - export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional - zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m' - source <(${lib.getExe pkgs.carapace} _carapace) - zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - - autoload -U select-word-style - select-word-style bash - - autoload -U up-line-or-beginning-search down-line-or-beginning-search - zle -N up-line-or-beginning-search - zle -N down-line-or-beginning-search - bindkey "^[OA" up-line-or-beginning-search - bindkey "^[OB" down-line-or-beginning-search - - bindkey "^[[1;5C" forward-word - bindkey "^[[1;5D" backward-word - bindkey "^[[3;5~" kill-word - bindkey "^H" backward-kill-word - - source <(${lib.getExe pkgs.fzf} --zsh) - - setopt NO_CASE_GLOB - - if command -v ${lib.getExe pkgs.nix-your-shell} > /dev/null; then - ${lib.getExe pkgs.nix-your-shell} -- zsh | source /dev/stdin - fi - - export EDITOR=nvim - - eval "$(${lib.getExe self'.packages.ohMyPosh} init zsh)" - - eval "$(${lib.getExe pkgs.devenv} hook zsh)" - - typeset -ag precmd_functions - if (( ! ''${precmd_functions[(I)__devenv_reload_apply]} )); then - precmd_functions+=(__devenv_reload_apply) - fi - if (( ! ''${precmd_functions[(I)__devenv_restore_path]} )); then - precmd_functions+=(__devenv_restore_path) - fi - ''; + zsh = lib.warnIf (flakeLocation == "") "Flake Location is undefined. Are you building in the right directory?" + inputs.wrappers.wrappers.zsh.wrap { + inherit pkgs; + runtimePkgs = [pkgs.carapace pkgs.devenv pkgs.fzf]; + zshAliases = { + ls = "${lib.getExe pkgs.lsd} -l"; + v = lib.getExe self'.packages.nvim; + cat = lib.getExe pkgs.bat; + lg = lib.getExe pkgs.lazygit; + man = "man -P \"${lib.getExe pkgs.bat} -p\""; + nsh = "nix-shell -p"; + nrs = + if flakeLocation != "" + then "( cd ${flakeLocation} && sudo nixos-rebuild switch --impure --flake . )" + else "echo 'Flake location not specified. Did you build with --impure?'"; + vinix = + if flakeLocation != "" + then "nvim --cmd 'cd ${flakeLocation}'" + else "echo 'Flake location not specified. Did you build with --impure?'"; }; + zshrc.content = '' + source ${./devenv.zsh} + + if (( ''${+terminfo[smkx]} )) && (( ''${+terminfo[rmkx]} )); then + function zle-line-init() { echoti smkx } + function zle-line-finish() { echoti rmkx } + zle -N zle-line-init + zle -N zle-line-finish + fi + + autoload -U compinit && compinit + export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional + zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m' + source <(${lib.getExe pkgs.carapace} _carapace) + zstyle ':completion:*' matcher-list 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + + autoload -U select-word-style + select-word-style bash + + autoload -U up-line-or-beginning-search down-line-or-beginning-search + zle -N up-line-or-beginning-search + zle -N down-line-or-beginning-search + bindkey "^[OA" up-line-or-beginning-search + bindkey "^[OB" down-line-or-beginning-search + + bindkey "^[[1;5C" forward-word + bindkey "^[[1;5D" backward-word + bindkey "^[[3;5~" kill-word + bindkey "^H" backward-kill-word + + source <(${lib.getExe pkgs.fzf} --zsh) + + setopt NO_CASE_GLOB + + if command -v ${lib.getExe pkgs.nix-your-shell} > /dev/null; then + ${lib.getExe pkgs.nix-your-shell} -- zsh | source /dev/stdin + fi + + export EDITOR=nvim + + eval "$(${lib.getExe self'.packages.ohMyPosh} init zsh)" + + eval "$(${lib.getExe pkgs.devenv} hook zsh)" + + typeset -ag precmd_functions + if (( ! ''${precmd_functions[(I)__devenv_reload_apply]} )); then + precmd_functions+=(__devenv_reload_apply) + fi + if (( ! ''${precmd_functions[(I)__devenv_restore_path]} )); then + precmd_functions+=(__devenv_restore_path) + fi + ''; + }; ohMyPosh = inputs.wrappers.wrappers.oh-my-posh.wrap { inherit pkgs; configFile = ./config.toml;