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

View file

@ -5,28 +5,65 @@ let
cfg = config.reo101.shell;
in
{
imports = [
imports =
[
];
options = {
options =
{
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 {
home.packages = with pkgs; [
config =
mkIf cfg.enable {
home.packages = with pkgs;
builtins.concatLists [
[
zsh
starship
]
(optionals cfg.direnv [
zoxide
])
(optionals cfg.zoxide [
direnv
])
];
programs.direnv = mkIf cfg.direnv {
enable = true;
nix-direnv = {
enable = true;
};
};
programs.zsh = {
enable = true;
enableCompletion = true;
# defaultKeymap = "viins";
shellAliases = {
# ll = "ls -l";
@ -38,10 +75,17 @@ in
path = "${config.xdg.dataHome}/zsh/history";
};
initExtra = ''
eval "$(zoxide init zsh)"
eval "$(direnv hook zsh)"
'';
initExtra =
builtins.concatStringsSep "\n"
[
(optionalString cfg.direnv ''
eval "$(${pkgs.zoxide}/bin/zoxide init zsh)"
'')
(optionalString cfg.zoxide ''
eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
'')
cfg.extraConfig
];
plugins = [
{
@ -64,6 +108,16 @@ in
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 = {
shell = [ "zsh" "-d" "-f" ];
when = ''[[ -z "$SSH_CLIENT" ]] && [[ `whoami` != "root" ]]'';
when = '' [ [ -z "$SSH_CLIENT" ] ] && [ [ `whoami` != "root" ] ] '';
format = "[$symbol$output]($style)[@](bold yellow)";
command = "whoami";
style = "fg:bright-white";
@ -228,7 +282,7 @@ in
custom.local_root = {
shell = [ "zsh" "-d" "-f" ];
when = ''[[ -z "$SSH_CLIENT" ]] && [[ `whoami` == "root" ]]'';
when = '' [ [ -z "$SSH_CLIENT" ] ] && [ [ `whoami` == "root" ] ] '';
format = "[ $output ]($style)[@](bold yellow)";
command = "whoami";
style = "bg:red fg:bright-white";
@ -236,7 +290,7 @@ in
custom.ssh = {
shell = [ "zsh" "-d" "-f" ];
when = ''[[ -n "$SSH_CLIENT" ]] && [[ `whoami` != "root" ]]'';
when = '' [ [ -n "$SSH_CLIENT" ] ] && [ [ `whoami` != "root" ] ] '';
format = "[ $symbol$output ]($style)[@](bold yellow)";
command = "whoami";
style = "bg:blue fg:bright-white";
@ -246,7 +300,7 @@ in
custom.ssh_root = {
shell = [ "zsh" "-d" "-f" ];
when = ''[[ -n "$SSH_CLIENT" ]] && [[ `whoami` == "root" ]]'';
when = '' [ [ -n "$SSH_CLIENT" ] ] && [ [ `whoami` == "root" ] ] '';
format = "[ $symbol$output ]($style)[@](bold yellow)";
command = "whoami";
style = "bg:red fg:bright-white";
@ -260,3 +314,8 @@ in
maintainers = with lib.maintainers; [ reo101 ];
};
}