home: move zsh and direnv to new modules

This commit is contained in:
Julian Mutter 2024-01-28 12:33:14 +01:00
parent 60ccfeaf39
commit 29d6b63382
5 changed files with 122 additions and 73 deletions

View File

@ -38,7 +38,11 @@
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [ ./home-manager/home.nix ];
modules = [
./home-manager/home.nix
./home-manager/modules/shell/zsh/default.nix
./home-manager/modules/shell/direnv.nix
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix

View File

@ -7,6 +7,13 @@
# DO NOT CHANGE!!!
home.stateVersion = "23.11";
modules = {
shell = {
zsh.enable = true;
direnv.enable = true;
};
};
home.packages = with pkgs; [
# Code formatters for use with doom emacs
nixfmt # nix
@ -24,9 +31,6 @@
# Further tools
lazygit
# TODO: migrate to module config
starship
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# (pkgs.writeShellScriptBin "my-hello" ''
@ -34,75 +38,7 @@
# '')
];
home.shellAliases = {
g = "git status";
fd = "fd -HI";
};
programs = {
direnv = {
enable = true;
enableZshIntegration = true;
};
starship = {
enable = true;
enableZshIntegration = true;
};
zsh = {
enable = true;
initExtra = ''
function go_dir_up() {
cd .. || return 1
}
function zle_go_dir_up() {
zle .kill-buffer
go_dir_up
zle .accept-line
}
fzf-z() {
dir=$(z | fzf --tiebreak=index --tac | sed -E 's/^[0-9]+[[:space:]]+//')
cd $dir
}
mkcd ()
{
mkdir -p -- "$1" && cd -P -- "$1"
}
zle -N zle_go_dir_up
bindkey "^[[1;3A" zle_go_dir_up
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
'';
zplug = {
enable = true;
plugins = [
# list of plugins: https://github.com/unixorn/awesome-zsh-plugins
{ name = "agkozak/zsh-z"; }
{ name = "mdumitru/last-working-dir"; }
{
name = "zsh-users/zsh-completions";
}
# make it behave like fish
{ name = "zsh-users/zsh-autosuggestions"; }
{ name = "zsh-users/zsh-history-substring-search"; }
{
name = "zsh-users/zsh-syntax-highlighting";
} # must be last sourced plugin
];
};
};
neovim = let
toLua = str: ''
lua << EOF
@ -169,7 +105,6 @@
source = ../alacritty;
recursive = true;
};
".config/starship.toml".source = ../starship/starship.toml;
};
# Home Manager can also manage your environment variables through
@ -180,6 +115,16 @@
# or
# /etc/profiles/per-user/julian/etc/profile.d/hm-session-vars.sh
#
#
home.shellAliases = {
g = "git status";
fd = "fd -HI";
ls = "ls --color";
la = "ls -Alh --color";
grep = "grep --color";
};
home.sessionVariables = {
TERMINAL = "alacritty";
EDITOR = "nvim";

View File

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.modules.shell.direnv;
in {
options.modules.shell.direnv = { enable = mkOption { default = false; }; };
config = mkIf cfg.enable {
programs.direnv = {
enable = true;
enableZshIntegration = true;
};
};
}

View File

@ -0,0 +1,75 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.modules.shell.zsh;
in {
options.modules.shell.zsh = { enable = mkOption { default = false; }; };
config = mkIf cfg.enable {
home.file = {
".config/starship.toml".source = ../../../../starship/starship.toml;
};
home.packages = with pkgs; [ starship ];
programs.starship = {
enable = true;
enableZshIntegration = true;
};
programs.zsh = {
enable = true;
initExtra = ''
function go_dir_up() {
cd .. || return 1
}
function zle_go_dir_up() {
zle .kill-buffer
go_dir_up
zle .accept-line
}
fzf-z() {
dir=$(z | fzf --tiebreak=index --tac | sed -E 's/^[0-9]+[[:space:]]+//')
cd $dir
}
mkcd ()
{
mkdir -p -- "$1" && cd -P -- "$1"
}
zle -N zle_go_dir_up
bindkey "^[[1;3A" zle_go_dir_up
bindkey "^[[A" history-substring-search-up
bindkey "^[[B" history-substring-search-down
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
'';
zplug = {
enable = true;
plugins = [
# list of plugins: https://github.com/unixorn/awesome-zsh-plugins
{ name = "agkozak/zsh-z"; }
{ name = "mdumitru/last-working-dir"; }
{
name = "zsh-users/zsh-completions";
}
# make it behave like fish
{ name = "zsh-users/zsh-autosuggestions"; }
{ name = "zsh-users/zsh-history-substring-search"; }
{
name = "zsh-users/zsh-syntax-highlighting";
} # must be last sourced plugin
];
};
};
};
}

View File

@ -0,0 +1,10 @@
{ config, lib, pkgs, ... }:
with lib;
let cfg = config.modules.X;
in {
options.modules.X = { enable = mkOption { default = false; }; };
config = mkIf cfg.enable { };
}