nixos-config/shared/zsh.nix

98 lines
2.8 KiB
Nix

{ pkgs, config, lib, ... }:
let
switch = pkgs.writeShellScript "switch.sh" ''
OUT_PATH=/tmp/nixos-rebuild-nom-$(date +%s)
${lib.getExe pkgs.nix-output-monitor} build /etc/nixos\#nixosConfigurations.${config.networking.hostName}.config.system.build.toplevel -o $OUT_PATH
${pkgs.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set $OUT_PATH
$OUT_PATH/bin/switch-to-configuration switch
unlink $OUT_PATH
'';
garbage = pkgs.writeShellScript "garbage.sh" ''
nix-collect-garbage -d
echo Cleaning up boot entries...
/run/current-system/bin/switch-to-configuration boot
echo Done
'';
in
{
programs.command-not-found.enable = false;
programs.nix-index-database.comma.enable = true;
environment.systemPackages = with pkgs; [
bat
eza
duf
trash-cli
nix-output-monitor
iperf
jq
helix
nushell
atuin
nmap
killall
];
users.defaultUserShell = pkgs.zsh;
programs.fzf = {
keybindings = true;
};
programs.zsh =
{
enable = true;
shellAliases = {
rm = "trash";
ls = "eza --icons";
l = "ls -l";
ll = "ls -la";
la = "ls -a";
less = "bat";
run0 = "run0 --setenv=PATH=$PATH --setenv=LOCALE_ARCHIVE=$LOCALE_ARCHIVE";
update = "cd /etc/nixos && nix flake update";
switch = "run0 ${switch}";
};
histSize = 100000;
histFile = "~/.local/share/zsh/history";
syntaxHighlighting.enable = true;
autosuggestions = {
enable = true;
highlightStyle = "fg=#00bbbb,bold";
};
shellInit = ''
zsh-newuser-install () {}
'';
interactiveShellInit =
''
export ZVM_FAST_ESCAPE=true
# fix for networkctl
zstyle ':completion:*:complete:networkctl:*' list-grouped true
source ${pkgs.agdsn-zsh-config}/etc/zsh/zshrc
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh
zvm_after_init_commands+=(eval "$(atuin init zsh --disable-up-arrow)")
unsetopt extendedglob
prompt_dir() {
prompt_segment blue $CURRENT_FG '%c'
}
garbage() {
${pkgs.home-manager}/bin/home-manager expire-generations "-0 days"
run0 --setenv=PATH=$PATH --setenv=LOCALE_ARCHIVE=$LOCALE_ARCHIVE ${garbage}
}
sysdiff() {
echo System package diff:
${config.nix.package}/bin/nix store diff-closures $(command ls -d /nix/var/nix/profiles/system-* | tail -2)
}
'';
promptInit =
''
# if [[ "$(hostname)" == "thinkpad" ]]
# then
# cat ${../images/cat.sixel}
# fi
eval "$(${pkgs.zoxide}/bin/zoxide init zsh)"
'';
};
}