feat(reo101-shell): add more options

This commit is contained in:
reo101 2023-02-17 02:47:22 +02:00
parent 0532f7e843
commit b51df48e6e
Signed by: reo101
GPG key ID: 675AA7EF13964ACB
2 changed files with 309 additions and 248 deletions

View file

@ -1,7 +1,7 @@
{ inputs, outputs, lib, pkgs, config, ... }: { inputs, outputs, lib, pkgs, config, ... }:
{ {
imports = builtins.attrValues outputs.homeManagerModules ++ [ imports = [
inputs.wired.homeManagerModules.default inputs.wired.homeManagerModules.default
]; ];
@ -47,9 +47,9 @@
vifm vifm
## Shell ## Shell
zsh # zsh
starship # starship
zoxide # zoxide
ripgrep ripgrep
## Dhall ## Dhall
@ -89,6 +89,8 @@
reo101.shell = { reo101.shell = {
enable = true; enable = true;
direnv = true;
zoxide = true;
}; };
systemd.user.services."swww" = { systemd.user.services."swww" = {

View file

@ -5,28 +5,65 @@ let
cfg = config.reo101.shell; cfg = config.reo101.shell;
in in
{ {
imports = [ imports =
[
]; ];
options = { options =
{
reo101.shell = { reo101.shell = {
enable = mkEnableOption "reo101 zsh config"; enable = mkEnableOption "reo101 zsh setup";
# ... username = mkOption {
description = "Username to be used in prompt";
type = types.str;
default = "${config.home.username}";
};
direnv = mkOption {
description = "Integrate with direnv";
type = types.bool;
default = true;
};
zoxide = mkOption {
description = "Integrate with zoxide";
type = types.bool;
default = true;
};
extraConfig = mkOption {
type = types.str;
description = "Extra zsh config";
default = ''
'';
};
}; };
}; };
config = mkIf cfg.enable { config =
home.packages = with pkgs; [ mkIf cfg.enable {
home.packages = with pkgs;
builtins.concatLists [
[
zsh zsh
starship starship
]
(optionals cfg.direnv [
zoxide zoxide
])
(optionals cfg.zoxide [
direnv direnv
])
]; ];
programs.direnv = mkIf cfg.direnv {
enable = true;
nix-direnv = {
enable = true;
};
};
programs.zsh = { programs.zsh = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
# defaultKeymap = "viins";
shellAliases = { shellAliases = {
# ll = "ls -l"; # ll = "ls -l";
@ -38,10 +75,17 @@ in
path = "${config.xdg.dataHome}/zsh/history"; path = "${config.xdg.dataHome}/zsh/history";
}; };
initExtra = '' initExtra =
eval "$(zoxide init zsh)" builtins.concatStringsSep "\n"
eval "$(direnv hook zsh)" [
''; (optionalString cfg.direnv ''
eval "$(${pkgs.zoxide}/bin/zoxide init zsh)"
'')
(optionalString cfg.zoxide ''
eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
'')
cfg.extraConfig
];
plugins = [ plugins = [
{ {
@ -64,6 +108,16 @@ in
sha256 = "4kma7Sx2RGWa9J4gr+U89ArxpM2/b8H9ytQ2pNCv6is="; sha256 = "4kma7Sx2RGWa9J4gr+U89ArxpM2/b8H9ytQ2pNCv6is=";
}; };
} }
{
name = "zsh-vi-mode";
file = "zsh-vi-mode.plugin.zsh";
src = pkgs.fetchFromGitHub {
owner = "jeffreytse";
repo = "zsh-vi-mode";
rev = "v0.9.0";
sha256 = "sha256-KQ7UKudrpqUwI6gMluDTVN0qKpB15PI5P1YHHCBIlpg=";
};
}
]; ];
}; };
@ -219,7 +273,7 @@ in
custom.local = { custom.local = {
shell = [ "zsh" "-d" "-f" ]; shell = [ "zsh" "-d" "-f" ];
when = ''[[ -z "$SSH_CLIENT" ]] && [[ `whoami` != "root" ]]''; when = '' [ [ -z "$SSH_CLIENT" ] ] && [ [ `whoami` != "root" ] ] '';
format = "[$symbol$output]($style)[@](bold yellow)"; format = "[$symbol$output]($style)[@](bold yellow)";
command = "whoami"; command = "whoami";
style = "fg:bright-white"; style = "fg:bright-white";
@ -228,7 +282,7 @@ in
custom.local_root = { custom.local_root = {
shell = [ "zsh" "-d" "-f" ]; shell = [ "zsh" "-d" "-f" ];
when = ''[[ -z "$SSH_CLIENT" ]] && [[ `whoami` == "root" ]]''; when = '' [ [ -z "$SSH_CLIENT" ] ] && [ [ `whoami` == "root" ] ] '';
format = "[ $output ]($style)[@](bold yellow)"; format = "[ $output ]($style)[@](bold yellow)";
command = "whoami"; command = "whoami";
style = "bg:red fg:bright-white"; style = "bg:red fg:bright-white";
@ -236,7 +290,7 @@ in
custom.ssh = { custom.ssh = {
shell = [ "zsh" "-d" "-f" ]; shell = [ "zsh" "-d" "-f" ];
when = ''[[ -n "$SSH_CLIENT" ]] && [[ `whoami` != "root" ]]''; when = '' [ [ -n "$SSH_CLIENT" ] ] && [ [ `whoami` != "root" ] ] '';
format = "[ $symbol$output ]($style)[@](bold yellow)"; format = "[ $symbol$output ]($style)[@](bold yellow)";
command = "whoami"; command = "whoami";
style = "bg:blue fg:bright-white"; style = "bg:blue fg:bright-white";
@ -246,7 +300,7 @@ in
custom.ssh_root = { custom.ssh_root = {
shell = [ "zsh" "-d" "-f" ]; shell = [ "zsh" "-d" "-f" ];
when = ''[[ -n "$SSH_CLIENT" ]] && [[ `whoami` == "root" ]]''; when = '' [ [ -n "$SSH_CLIENT" ] ] && [ [ `whoami` == "root" ] ] '';
format = "[ $symbol$output ]($style)[@](bold yellow)"; format = "[ $symbol$output ]($style)[@](bold yellow)";
command = "whoami"; command = "whoami";
style = "bg:red fg:bright-white"; style = "bg:red fg:bright-white";
@ -260,3 +314,8 @@ in
maintainers = with lib.maintainers; [ reo101 ]; maintainers = with lib.maintainers; [ reo101 ];
}; };
} }