[zsh] Move into user config

This commit is contained in:
Tibo De Peuter 2023-10-19 22:24:04 +02:00
parent 7a7edb68a6
commit 40b24908c3
8 changed files with 134 additions and 90 deletions

View file

@ -41,6 +41,7 @@
sharedOverlays = [ sharedOverlays = [
(import ./overlays/letter) (import ./overlays/letter)
(import ./overlays/icosystem) (import ./overlays/icosystem)
(import ./overlays/cmdtime)
]; ];
hostDefaults = { hostDefaults = {

View file

@ -46,10 +46,15 @@
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
git git
vim
wget wget
zenith-nvidia zenith-nvidia
]; ];
programs = {
zsh.enable = true;
};
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
networking.hostName = "Tibo-NixFat"; networking.hostName = "Tibo-NixFat";

View file

@ -1,5 +0,0 @@
{
imports = [
./zsh
];
}

View file

@ -1,77 +0,0 @@
{ config, lib, pkgs, ... }:
{
programs.zsh.enable = true;
users.users.tdpeuter.shell = pkgs.zsh;
home-manager.users.tdpeuter = { pkgs, ... }: {
home = {
packages = with pkgs; [
font-awesome
fzf
];
file = {
".oh-my-zsh".source = ../../../../stow/zsh/.oh-my-zsh;
};
};
programs.zsh = {
enable = true;
enableAutosuggestions = true;
enableSyntaxHighlighting = true;
history = {
expireDuplicatesFirst = true;
extended = true;
};
initExtra = ''
eval "$(direnv hook zsh)"
# Add fzf
if [ -x "$(command -v fzf-share)" ]; then
source "$(fzf-share)/key-bindings.zsh"
source "$(fzf-share)/completion.zsh"
fi
'';
oh-my-zsh = {
enable = true;
custom = "$HOME/.oh-my-zsh";
plugins = [
"dirhistory"
"git"
"screen"
];
theme = "mrfortem";
};
plugins = [
{
name = "cmdtime";
src = pkgs.fetchFromGitHub {
owner = "tom-auger";
repo = "cmdtime";
rev = "ffc72641dcfa0ee6666ceb1dc712b61be30a1e8b";
hash = "sha256-v6wCfNoPXDD3sS6yUYE6lre8Ir1yJcLGoAW3O8sUOCg=";
};
}
];
shellAliases = {
cp = "cp -i"; # Confirm before overwriting something
df = "df -h";
free = "free -m";
ll = "ls -la";
np = "nano -w PKGBUILD";
more = "less";
hgrep = "history | grep";
gs = "git status";
update = ''
pushd ~/projects/sisyphus/nixos
nix flake update
sudo nixos-rebuild switch --flake .# --show-trace
popd
'';
};
};
};
}

View file

@ -18,9 +18,11 @@ in {
config.users.groups.wheel.name config.users.groups.wheel.name
]; ];
initialPassword = "ChangeMe"; initialPassword = "ChangeMe";
shell = pkgs.zsh;
}; };
fonts.fonts = with pkgs; [ fonts.fonts = with pkgs; [
font-awesome # Dependency of zsh
font-awesome_5 # Dependency of Vifm config font-awesome_5 # Dependency of Vifm config
noto-fonts # Dependency of Zellij config noto-fonts # Dependency of Zellij config
noto-fonts-cjk # Dependency of Zellij config noto-fonts-cjk # Dependency of Zellij config
@ -38,7 +40,9 @@ in {
# and the configuration files will be put in place for you. # and the configuration files will be put in place for you.
packages = (with pkgs; [ packages = (with pkgs; [
chafa # Terminal image viewer chafa # Terminal image viewer
cmdtime # Zsh plugin
duf # Df alternative duf # Df alternative
fzf
glow # Terminal Markdown renderer glow # Terminal Markdown renderer
jellyfin-media-player jellyfin-media-player
kitty kitty
@ -53,6 +57,9 @@ in {
vifm # File manager vifm # File manager
zathura # PDF viewer zathura # PDF viewer
zellij # Tmux + screen alternative zellij # Tmux + screen alternative
zsh
zsh-autosuggestions
zsh-syntax-highlighting
]) ++ (with pkgs-unstable; [ ]) ++ (with pkgs-unstable; [
mpv mpv
]) ++ (with pkgs.vimPlugins; [ ]) ++ (with pkgs.vimPlugins; [
@ -65,37 +72,65 @@ in {
".config/alacritty" = lib.mkIf (builtins.elem pkgs.alacritty installedPkgs) { ".config/alacritty" = lib.mkIf (builtins.elem pkgs.alacritty installedPkgs) {
source = ../../../../stow/alacritty/.config/alacritty; source = ../../../../stow/alacritty/.config/alacritty;
}; };
".config/git" = lib.mkIf (builtins.elem pkgs.git installedPkgs) { ".config/git" = {
enable = (builtins.elem pkgs.git installedPkgs);
source = ../../../../stow/git/.config/git; source = ../../../../stow/git/.config/git;
recursive = true;
}; };
".config/kitty" = { ".config/kitty" = {
enable = builtins.elem pkgs.kitty installedPkgs; enable = builtins.elem pkgs.kitty installedPkgs;
source = ../../../../stow/kitty/.config/kitty; source = ../../../../stow/kitty/.config/kitty;
recursive = true; recursive = true;
}; };
".config/mpv" = lib.mkIf (builtins.elem pkgs-unstable.mpv installedPkgs) { ".config/mpv" = {
enable = (builtins.elem pkgs-unstable.mpv installedPkgs);
source = ../../../../stow/mpv/.config/mpv; source = ../../../../stow/mpv/.config/mpv;
}; };
".ssh/config" = lib.mkIf config.sisyphus.programs.ssh.enable { ".ssh/config" = lib.mkIf config.sisyphus.programs.ssh.enable {
source = ../../../../stow/ssh/.ssh/config; source = ../../../../stow/ssh/.ssh/config;
}; };
".config/vifm" = lib.mkIf (builtins.elem pkgs.vifm installedPkgs) { ".config/vifm" = {
enable = (builtins.elem pkgs.vifm installedPkgs);
source = ../../../../stow/vifm/.config/vifm; source = ../../../../stow/vifm/.config/vifm;
recursive = true; recursive = true;
}; };
".config/zellij" = lib.mkIf (builtins.elem pkgs.zellij installedPkgs) { ".config/zellij" = {
enable = (builtins.elem pkgs.zellij installedPkgs);
source = ../../../../stow/zellij/.config/zellij; source = ../../../../stow/zellij/.config/zellij;
}; };
".vim" = lib.mkIf (builtins.elem pkgs.vim installedPkgs) { ".oh-my-zsh" = {
enable = (builtins.elem pkgs.zsh installedPkgs);
source = ../../../../stow/zsh/.oh-my-zsh;
};
".vim" = {
enable = (builtins.elem pkgs.vim installedPkgs);
source = ../../../../stow/vim/.vim; source = ../../../../stow/vim/.vim;
recursive = true; recursive = true;
}; };
".vim/autoload/plug.vim" = lib.mkIf (builtins.elem pkgs.vim installedPkgs) { ".vim/autoload/plug.vim" = {
enable = (builtins.elem pkgs.vim installedPkgs);
source = "${pkgs.vimPlugins.vim-plug}/plug.vim"; source = "${pkgs.vimPlugins.vim-plug}/plug.vim";
}; };
".vimrc" = lib.mkIf (builtins.elem pkgs.vim installedPkgs) { ".vimrc" = {
enable = (builtins.elem pkgs.vim installedPkgs);
source = ../../../../stow/vim/.vimrc; source = ../../../../stow/vim/.vimrc;
}; };
".zshrc" = {
enable = (config.users.users.tdpeuter.shell == pkgs.zsh);
source = ../../../../stow/zsh/.zshrc;
};
".zsh/plugins/cmdtime/cmdtime.plugin.zsh" = {
enable = (builtins.elem pkgs.cmdtime installedPkgs);
source = "${pkgs.cmdtime}/share/cmdtime/cmdtime.plugin.zsh";
};
".zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" = {
enable = (builtins.elem pkgs.zsh-autosuggestions installedPkgs);
source = "${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh";
};
".zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" = {
enable = (builtins.elem pkgs.zsh-syntax-highlighting installedPkgs);
source = "${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh";
};
}; };
}; };

View file

@ -0,0 +1,17 @@
final: prev: {
cmdtime = final.stdenv.mkDerivation {
name = "cmdtime";
version = "v0.0.0";
src = final.fetchFromGitHub {
owner = "tom-auger";
repo = "cmdtime";
rev = "ffc72641dcfa0ee6666ceb1dc712b61be30a1e8b";
hash = "sha256-v6wCfNoPXDD3sS6yUYE6lre8Ir1yJcLGoAW3O8sUOCg=";
};
installPhase = ''
mkdir -p $out/share/cmdtime
cp $src/cmdtime.plugin.zsh $out/share/cmdtime.plugin.zsh
'';
};
}

View file

@ -1,5 +1,5 @@
# #
# ~/.oh-my-zsh/themes/mrfortem.zsh-theme # ~/.oh-my-zsh/themes/tdpeuter.zsh-theme
# Stolen from gentoo-theme and gianni # Stolen from gentoo-theme and gianni
# #

68
stow/zsh/.zshrc Normal file
View file

@ -0,0 +1,68 @@
typeset -U path cdpath fpath manpath
path+="$HOME/.zsh/plugins/cmdtime"
fpath+="$HOME/.zsh/plugins/cmdtime"
plugins=(dirhistory git screen)
ZSH_CUSTOM="$HOME/.oh-my-zsh"
ZSH_THEME="tdpeuter"
# source $ZSH/oh-my-zsh.sh
if [[ -f "$HOME/.zsh/plugins/cmdtime/cmdtime.plugin.zsh" ]]; then
source "$HOME/.zsh/plugins/cmdtime/cmdtime.plugin.zsh"
fi
if [[ -f "$HOME/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then
source "$HOME/.zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
fi
if [[ -f "$HOME/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then
source "$HOME/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
fi
# History options should be set in .zshrc and after oh-my-zsh sourcing.
# See https://github.com/nix-community/home-manager/issues/177.
HISTSIZE="10000"
SAVEHIST="10000"
HISTFILE="$HOME/.zsh_history"
mkdir -p "$(dirname "$HISTFILE")"
setopt HIST_FCNTL_LOCK
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_EXPIRE_DUPS_FIRST
setopt SHARE_HISTORY
setopt EXTENDED_HISTORY
# Add direnv
if [ -x "$(command -v direnv)" ]; then
eval "$(direnv hook zsh)"
fi
# Add fzf
if [ -x "$(command -v fzf-share)" ]; then
source "$(fzf-share)/key-bindings.zsh"
source "$(fzf-share)/completion.zsh"
fi
# Aliases
alias cp='cp -i'
alias df='df -h'
alias free='free -m'
alias gs='git status'
alias hgrep='history | grep'
alias ll='ls -la'
alias more='less'
alias np='nano -w PKGBUILD'
alias update='pushd ~/projects/sisyphus/nixos
nix flake update
sudo nixos-rebuild switch --flake .# --show-trace
popd
'
# -- Barrier --
for profile in ${(z)NIX_PROFILES}; do
fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
done