-
Notifications
You must be signed in to change notification settings - Fork 111
/
default.nix
166 lines (137 loc) · 3.94 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
{ lib, pkgs, ... }:
let
inherit (builtins) concatStringsSep;
inherit (lib) fileContents;
in
{
users.defaultUserShell = pkgs.zsh;
environment = {
etc.zshrc.text = lib.mkBefore ''
if [[ -r "${"\${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-\${(%):-%n}"}.zsh" ]]; then
source "${"\${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-\${(%):-%n}"}.zsh"
fi
'';
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;
};
shellAliases = {
cat = "${pkgs.bat}/bin/bat";
df = "df -h";
du = "du -h";
ls = "exa";
l = "ls -lhg --git";
la = "l -a";
t = "l -T";
ta = "la -T";
ps = "${pkgs.procs}/bin/procs";
rz = "exec zsh";
};
systemPackages = with pkgs; [
bat
bzip2
devshell.cli
exa
gitAndTools.hub
gzip
lrzip
p7zip
procs
skim
unrar
unzip
xz
zsh-completions
];
};
programs.zsh = {
enable = true;
enableGlobalCompInit = false;
histSize = 10000;
setOptions = [
"extendedglob"
"incappendhistory"
"sharehistory"
"histignoredups"
"histfcntllock"
"histreduceblanks"
"histignorespace"
"histallowclobber"
"autocd"
"cdablevars"
"nomultios"
"pushdignoredups"
"autocontinue"
"promptsubst"
];
promptInit =
let
p10k = pkgs.writeText "pk10.zsh" (fileContents ./p10k.zsh);
p10k-linux = pkgs.writeText "pk10-linux.zsh" (fileContents ./p10k-linux.zsh);
in
''
source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
[[ -z $DISPLAY && -z $WAYLAND_DISPLAY ]] \
&& source ${p10k-linux} \
|| source ${p10k}
'';
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);
localCompletions = toString ./completions;
in
''
${plugins}
fpath+=( ${functions} ${localCompletions} )
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
'';
};
}