chore: refactor user modules
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.modules.bash;
|
||||
cfg = config.home.shell.bash;
|
||||
in {
|
||||
options.modules.bash = {
|
||||
options.home.shell.bash = {
|
||||
enable = mkEnableOption "Enables bash";
|
||||
aliases = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
|
||||
@@ -61,7 +61,7 @@ with lib; let
|
||||
please = "sudo -A";
|
||||
wget = "wget --hsts-file=\"$XDG_DATA_HOME/wget-hsts\" -c";
|
||||
};
|
||||
cfg = config.modules.shell;
|
||||
cfg = config.home.shell;
|
||||
in {
|
||||
imports = [
|
||||
./bash.nix
|
||||
@@ -69,73 +69,22 @@ in {
|
||||
./starship.nix
|
||||
./tmux.nix
|
||||
./zsh.nix
|
||||
./zoxide.nix
|
||||
];
|
||||
|
||||
options.modules.shell = {
|
||||
eatIntegration = mkEnableOption "Enable Emacs Eat integration in Bash or Zsh";
|
||||
enableBash = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Enables bash";
|
||||
options.home.shell.fullDesktop = mkEnableOption "Enable all shells";
|
||||
config.home.shell = {
|
||||
enableShellIntegration = cfg.bash.enable or cfg.zsh.enable or cfg.fish.enable;
|
||||
bash = {
|
||||
aliases = mkDefault aliases;
|
||||
enable = mkDefault cfg.fullDesktop;
|
||||
};
|
||||
enableFish = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Enables fish";
|
||||
fish = {
|
||||
abbrs = mkDefault aliases;
|
||||
enable = mkDefault cfg.fullDesktop;
|
||||
};
|
||||
enableZsh = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Enables zsh";
|
||||
};
|
||||
starship = {
|
||||
enable = mkEnableOption "Enables the starship prompt.";
|
||||
jjIntegration = mkEnableOption "Enables Jujutsu integration in starship.";
|
||||
};
|
||||
tmux.enable = mkEnableOption "Enables tmux";
|
||||
zoxide = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "enables zoxide";
|
||||
};
|
||||
replaceCd = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "makes zoxide replace cd";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
home.shell = {
|
||||
enableFishIntegration = mkDefault cfg.enableFish;
|
||||
enableBashIntegration = mkDefault cfg.enableBash;
|
||||
enableZshIntegration = mkDefault cfg.enableZsh;
|
||||
};
|
||||
|
||||
modules = {
|
||||
fish = {
|
||||
enable = mkDefault cfg.enableFish;
|
||||
abbrs = mkDefault aliases;
|
||||
};
|
||||
bash = {
|
||||
enable = mkDefault cfg.enableBash;
|
||||
aliases = mkDefault aliases;
|
||||
};
|
||||
zsh = {
|
||||
enable = mkDefault cfg.enableZsh;
|
||||
abbrs = mkDefault aliases;
|
||||
};
|
||||
tmux.enable = cfg.tmux.enable;
|
||||
inherit (cfg) starship;
|
||||
};
|
||||
|
||||
programs.zoxide = mkIf cfg.zoxide.enable {
|
||||
enable = true;
|
||||
options = mkIf cfg.zoxide.replaceCd [
|
||||
"--cmd cd"
|
||||
];
|
||||
zsh = {
|
||||
abbrs = mkDefault aliases;
|
||||
enable = mkDefault cfg.fullDesktop;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.modules.fish;
|
||||
cfg = config.home.shell.fish;
|
||||
in {
|
||||
options.modules.fish = {
|
||||
options.home.shell.fish = {
|
||||
enable = lib.mkEnableOption "enables fish";
|
||||
abbrs = lib.mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
|
||||
@@ -4,17 +4,21 @@
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.modules.starship;
|
||||
cfg = config.home.shell.starship;
|
||||
in {
|
||||
options.modules.starship = {
|
||||
options.home.shell.starship = {
|
||||
enable = mkEnableOption "Enables the starship prompt.";
|
||||
jjIntegration = mkEnableOption "Enables Jujutsu integration in starship.";
|
||||
jjIntegration = mkOption {
|
||||
description = "Enable Jujutsu integration in starship";
|
||||
default = config.programs.jujutsu.enable;
|
||||
type = types.bool;
|
||||
};
|
||||
};
|
||||
|
||||
config.programs.starship = mkIf cfg.enable {
|
||||
inherit (cfg) enable;
|
||||
enableTransience = true;
|
||||
settings = {
|
||||
settings = mkIf cfg.jjIntegration {
|
||||
custom.jj = {
|
||||
description = "The current jj status";
|
||||
detect_folders = [".jj"];
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.modules.tmux;
|
||||
cfg = config.home.shell.tmux;
|
||||
in {
|
||||
options.modules.tmux.enable = mkEnableOption "Enable tmux";
|
||||
options.home.shell.tmux.enable = mkEnableOption "Enable tmux";
|
||||
config.programs.tmux = mkIf cfg.enable {
|
||||
inherit (cfg) enable;
|
||||
baseIndex = 1;
|
||||
|
||||
19
users/modules/shell/zoxide.nix
Normal file
19
users/modules/shell/zoxide.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.shell.zoxide;
|
||||
in {
|
||||
options.home.shell.zoxide = {
|
||||
enable = mkEnableOption "Enable zoxide";
|
||||
replaceCd = mkEnableOption "Replace cd with zoxide";
|
||||
};
|
||||
config.programs.zoxide = mkIf cfg.enable {
|
||||
inherit (cfg) enable;
|
||||
options = mkIf cfg.replaceCd [
|
||||
"--cmd cd"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -5,9 +5,9 @@
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.modules.zsh;
|
||||
cfg = config.home.shell.zsh;
|
||||
in {
|
||||
options.modules.zsh = {
|
||||
options.home.shell.zsh = {
|
||||
enable = lib.mkEnableOption "Enables zsh";
|
||||
abbrs = lib.mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
@@ -24,70 +24,73 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
config.programs.zsh = lib.mkIf cfg.enable {
|
||||
enable = true;
|
||||
autocd = true;
|
||||
autosuggestion = {
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
strategy = ["match_prev_cmd" "completion"];
|
||||
};
|
||||
enableCompletion = true;
|
||||
history = {
|
||||
findNoDups = true;
|
||||
ignoreAllDups = true;
|
||||
ignoreDups = true;
|
||||
ignoreSpace = true;
|
||||
path = "${config.xdg.dataHome}/zsh/zsh_history";
|
||||
saveNoDups = true;
|
||||
};
|
||||
historySubstringSearch.enable = true;
|
||||
initContent = with lib;
|
||||
concatLines [
|
||||
''
|
||||
bindkey -e
|
||||
bindkey '^p' history-search-backward
|
||||
bindkey '^n' history-search-forward
|
||||
autocd = true;
|
||||
autosuggestion = {
|
||||
enable = true;
|
||||
strategy = ["match_prev_cmd" "completion"];
|
||||
};
|
||||
enableCompletion = true;
|
||||
enableVteIntegration = true;
|
||||
history = {
|
||||
findNoDups = true;
|
||||
ignoreAllDups = true;
|
||||
ignoreDups = true;
|
||||
ignoreSpace = true;
|
||||
path = "${config.xdg.dataHome}/zsh/zsh_history";
|
||||
saveNoDups = true;
|
||||
};
|
||||
historySubstringSearch.enable = true;
|
||||
initContent = with lib;
|
||||
concatLines [
|
||||
''
|
||||
bindkey -e
|
||||
bindkey '^p' history-search-backward
|
||||
bindkey '^n' history-search-forward
|
||||
|
||||
# Completion styling
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
||||
zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}"
|
||||
zstyle ':completion:*' menu no
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview '${pkgs.eza}/bin/eza $realpath'
|
||||
''
|
||||
(strings.optionalString cfg.eatIntegration ''[ -n "$EAT_SHELL_INTEGRATION_DIR" ] && source "$EAT_SHELL_INTEGRATION_DIR/zsh"'')
|
||||
cfg.zshrcExtra
|
||||
];
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
# Completion styling
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
|
||||
zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}"
|
||||
zstyle ':completion:*' menu no
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview '${pkgs.eza}/bin/eza $realpath'
|
||||
''
|
||||
(strings.optionalString cfg.eatIntegration ''[ -n "$EAT_SHELL_INTEGRATION_DIR" ] && source "$EAT_SHELL_INTEGRATION_DIR/zsh"'')
|
||||
cfg.zshrcExtra
|
||||
];
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
plugins = [
|
||||
"dirhistory"
|
||||
"sudo"
|
||||
];
|
||||
};
|
||||
plugins = [
|
||||
"dirhistory"
|
||||
"sudo"
|
||||
{
|
||||
name = "fzf-tab";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Aloxaf";
|
||||
repo = "fzf-tab";
|
||||
rev = "v1.2.0";
|
||||
sha256 = "sha256-q26XVS/LcyZPRqDNwKKA9exgBByE0muyuNb0Bbar2lY=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "zsh-autopair";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "hlissner";
|
||||
repo = "zsh-autopair";
|
||||
rev = "449a7c3d095bc8f3d78cf37b9549f8bb4c383f3d";
|
||||
sha256 = "sha256-3zvOgIi+q7+sTXrT+r/4v98qjeiEL4Wh64rxBYnwJvQ=";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
plugins = [
|
||||
{
|
||||
name = "fzf-tab";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Aloxaf";
|
||||
repo = "fzf-tab";
|
||||
rev = "v1.2.0";
|
||||
sha256 = "sha256-q26XVS/LcyZPRqDNwKKA9exgBByE0muyuNb0Bbar2lY=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "zsh-autopair";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "hlissner";
|
||||
repo = "zsh-autopair";
|
||||
rev = "449a7c3d095bc8f3d78cf37b9549f8bb4c383f3d";
|
||||
sha256 = "sha256-3zvOgIi+q7+sTXrT+r/4v98qjeiEL4Wh64rxBYnwJvQ=";
|
||||
};
|
||||
}
|
||||
];
|
||||
syntaxHighlighting.enable = true;
|
||||
zsh-abbr = {
|
||||
enable = true;
|
||||
abbreviations = cfg.abbrs;
|
||||
syntaxHighlighting.enable = true;
|
||||
zsh-abbr = {
|
||||
enable = true;
|
||||
abbreviations = cfg.abbrs;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user