home: move zsh and direnv to new modules
This commit is contained in:
parent
60ccfeaf39
commit
29d6b63382
@ -38,7 +38,11 @@
|
|||||||
|
|
||||||
# Specify your home configuration modules here, for example,
|
# Specify your home configuration modules here, for example,
|
||||||
# the path to your home.nix.
|
# 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
|
# Optionally use extraSpecialArgs
|
||||||
# to pass through arguments to home.nix
|
# to pass through arguments to home.nix
|
||||||
|
@ -7,6 +7,13 @@
|
|||||||
# DO NOT CHANGE!!!
|
# DO NOT CHANGE!!!
|
||||||
home.stateVersion = "23.11";
|
home.stateVersion = "23.11";
|
||||||
|
|
||||||
|
modules = {
|
||||||
|
shell = {
|
||||||
|
zsh.enable = true;
|
||||||
|
direnv.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
# Code formatters for use with doom emacs
|
# Code formatters for use with doom emacs
|
||||||
nixfmt # nix
|
nixfmt # nix
|
||||||
@ -24,9 +31,6 @@
|
|||||||
# Further tools
|
# Further tools
|
||||||
lazygit
|
lazygit
|
||||||
|
|
||||||
# TODO: migrate to module config
|
|
||||||
starship
|
|
||||||
|
|
||||||
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
|
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
|
||||||
|
|
||||||
# (pkgs.writeShellScriptBin "my-hello" ''
|
# (pkgs.writeShellScriptBin "my-hello" ''
|
||||||
@ -34,75 +38,7 @@
|
|||||||
# '')
|
# '')
|
||||||
];
|
];
|
||||||
|
|
||||||
home.shellAliases = {
|
|
||||||
g = "git status";
|
|
||||||
fd = "fd -HI";
|
|
||||||
};
|
|
||||||
|
|
||||||
programs = {
|
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
|
neovim = let
|
||||||
toLua = str: ''
|
toLua = str: ''
|
||||||
lua << EOF
|
lua << EOF
|
||||||
@ -169,7 +105,6 @@
|
|||||||
source = ../alacritty;
|
source = ../alacritty;
|
||||||
recursive = true;
|
recursive = true;
|
||||||
};
|
};
|
||||||
".config/starship.toml".source = ../starship/starship.toml;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Home Manager can also manage your environment variables through
|
# Home Manager can also manage your environment variables through
|
||||||
@ -180,6 +115,16 @@
|
|||||||
# or
|
# or
|
||||||
# /etc/profiles/per-user/julian/etc/profile.d/hm-session-vars.sh
|
# /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 = {
|
home.sessionVariables = {
|
||||||
TERMINAL = "alacritty";
|
TERMINAL = "alacritty";
|
||||||
EDITOR = "nvim";
|
EDITOR = "nvim";
|
||||||
|
15
home-manager/modules/shell/direnv.nix
Normal file
15
home-manager/modules/shell/direnv.nix
Normal 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
75
home-manager/modules/shell/zsh/default.nix
Normal file
75
home-manager/modules/shell/zsh/default.nix
Normal 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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
10
home-manager/templates/module.default.nix
Normal file
10
home-manager/templates/module.default.nix
Normal 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 { };
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user