2019-12-15 05:37:46 +01:00
|
|
|
{ lib, pkgs, ... }:
|
|
|
|
let
|
2020-01-04 06:06:31 +01:00
|
|
|
inherit (builtins) concatStringsSep;
|
2019-12-15 05:37:46 +01:00
|
|
|
|
2020-01-04 06:06:31 +01:00
|
|
|
inherit (lib) fileContents;
|
2019-12-15 05:37:46 +01:00
|
|
|
|
2020-07-31 06:17:28 +02:00
|
|
|
in
|
|
|
|
{
|
2019-12-15 05:37:46 +01:00
|
|
|
users.defaultUserShell = pkgs.zsh;
|
|
|
|
|
|
|
|
environment = {
|
2020-07-31 06:17:28 +02:00
|
|
|
sessionVariables =
|
|
|
|
let fd = "${pkgs.fd}/bin/fd -H";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
BAT_PAGER = "less";
|
|
|
|
SKIM_ALT_C_COMMAND =
|
|
|
|
let
|
|
|
|
alt_c_cmd = pkgs.writeScriptBin "cdr-skim.zsh" ''
|
|
|
|
#!${pkgs.zsh}/bin/zsh
|
|
|
|
${fileContents ./cdr-skim.zsh}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
"${alt_c_cmd}/bin/cdr-skim.zsh";
|
|
|
|
SKIM_DEFAULT_COMMAND = fd;
|
|
|
|
SKIM_CTRL_T_COMMAND = fd;
|
|
|
|
};
|
2019-12-15 05:37:46 +01:00
|
|
|
|
|
|
|
shellAliases = {
|
|
|
|
cat = "${pkgs.bat}/bin/bat";
|
|
|
|
|
|
|
|
df = "df -h";
|
|
|
|
du = "du -h";
|
|
|
|
|
2019-12-23 06:24:19 +01:00
|
|
|
ls = "exa";
|
2019-12-18 02:10:18 +01:00
|
|
|
l = "ls -lhg --git";
|
2019-12-15 05:37:46 +01:00
|
|
|
la = "l -a";
|
2019-12-23 06:24:19 +01:00
|
|
|
t = "l -T";
|
|
|
|
ta = "la -T";
|
2019-12-15 05:37:46 +01:00
|
|
|
|
2019-12-18 02:10:18 +01:00
|
|
|
ps = "${pkgs.procs}/bin/procs";
|
|
|
|
|
2019-12-15 05:37:46 +01:00
|
|
|
rz = "exec zsh";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemPackages = with pkgs; [
|
2019-12-18 02:10:18 +01:00
|
|
|
bat
|
2019-12-15 08:27:41 +01:00
|
|
|
bzip2
|
2020-12-29 07:12:27 +01:00
|
|
|
devshell
|
2019-12-18 02:10:18 +01:00
|
|
|
exa
|
2019-12-15 05:37:46 +01:00
|
|
|
gitAndTools.hub
|
2019-12-15 08:27:41 +01:00
|
|
|
gzip
|
|
|
|
lrzip
|
|
|
|
p7zip
|
2019-12-18 02:10:18 +01:00
|
|
|
procs
|
2019-12-15 05:37:46 +01:00
|
|
|
skim
|
2019-12-15 08:27:41 +01:00
|
|
|
unrar
|
|
|
|
unzip
|
|
|
|
xz
|
2019-12-18 02:10:18 +01:00
|
|
|
zsh-completions
|
2019-12-15 05:37:46 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
programs.zsh = {
|
|
|
|
enable = true;
|
|
|
|
|
2019-12-27 03:11:57 +01:00
|
|
|
enableGlobalCompInit = false;
|
|
|
|
|
|
|
|
histSize = 10000;
|
|
|
|
|
|
|
|
setOptions = [
|
|
|
|
"extendedglob"
|
|
|
|
"incappendhistory"
|
|
|
|
"sharehistory"
|
|
|
|
"histignoredups"
|
|
|
|
"histfcntllock"
|
|
|
|
"histreduceblanks"
|
|
|
|
"histignorespace"
|
|
|
|
"histallowclobber"
|
|
|
|
"autocd"
|
|
|
|
"cdablevars"
|
|
|
|
"nomultios"
|
|
|
|
"pushdignoredups"
|
|
|
|
"autocontinue"
|
|
|
|
"promptsubst"
|
|
|
|
];
|
|
|
|
|
2019-12-15 05:37:46 +01:00
|
|
|
promptInit = ''
|
2020-07-27 06:24:28 +02:00
|
|
|
eval "$(${pkgs.starship}/bin/starship init zsh)"
|
2019-12-15 05:37:46 +01:00
|
|
|
'';
|
|
|
|
|
2020-07-31 06:17:28 +02:00
|
|
|
interactiveShellInit =
|
|
|
|
let
|
|
|
|
zshrc = fileContents ./zshrc;
|
|
|
|
|
|
|
|
sources = with pkgs; [
|
|
|
|
./cdr.zsh
|
|
|
|
"${skim}/share/skim/completion.zsh"
|
|
|
|
"${oh-my-zsh}/share/oh-my-zsh/plugins/sudo/sudo.plugin.zsh"
|
|
|
|
"${oh-my-zsh}/share/oh-my-zsh/plugins/extract/extract.plugin.zsh"
|
|
|
|
"${zsh-you-should-use}/share/zsh/plugins/you-should-use/you-should-use.plugin.zsh"
|
|
|
|
"${zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
|
|
|
"${zsh-history-substring-search}/share/zsh-history-substring-search/zsh-history-substring-search.zsh"
|
|
|
|
];
|
|
|
|
|
|
|
|
source = map (source: "source ${source}") sources;
|
|
|
|
|
|
|
|
functions = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "zsh-functions";
|
|
|
|
src = ./functions;
|
|
|
|
|
|
|
|
ripgrep = "${pkgs.ripgrep}";
|
|
|
|
man = "${pkgs.man}";
|
|
|
|
exa = "${pkgs.exa}";
|
|
|
|
|
|
|
|
installPhase =
|
|
|
|
let basename = "\${file##*/}";
|
|
|
|
in
|
|
|
|
''
|
|
|
|
mkdir $out
|
|
|
|
|
|
|
|
for file in $src/*; do
|
|
|
|
substituteAll $file $out/${basename}
|
|
|
|
chmod 755 $out/${basename}
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
plugins = concatStringsSep "\n" ([
|
|
|
|
"${pkgs.any-nix-shell}/bin/any-nix-shell zsh --info-right | source /dev/stdin"
|
|
|
|
] ++ source);
|
|
|
|
|
|
|
|
in
|
|
|
|
''
|
|
|
|
${plugins}
|
|
|
|
|
|
|
|
fpath+=( ${functions} )
|
|
|
|
autoload -Uz ${functions}/*(:t)
|
|
|
|
|
|
|
|
${zshrc}
|
|
|
|
|
|
|
|
eval "$(${pkgs.direnv}/bin/direnv hook zsh)"
|
|
|
|
eval $(${pkgs.gitAndTools.hub}/bin/hub alias -s)
|
|
|
|
source ${pkgs.skim}/share/skim/key-bindings.zsh
|
|
|
|
|
|
|
|
# needs to remain at bottom so as not to be overwritten
|
|
|
|
bindkey jj vi-cmd-mode
|
|
|
|
'';
|
2019-12-15 05:37:46 +01:00
|
|
|
};
|
|
|
|
}
|