nixos configs
1{ pkgs, config, inputs, ... }:
2{
3 programs.zsh = {
4 enable = true;
5 autocd = true;
6 autosuggestion.enable = true;
7 enableCompletion = true;
8 shellAliases = {
9 ls = "${pkgs.eza}/bin/eza";
10 l = "${pkgs.eza}/bin/eza -l";
11 la = "${pkgs.eza}/bin/eza -la";
12 tree = "${pkgs.tre-command}/bin/tre";
13 cat = "${pkgs.bat}/bin/bat";
14 amend = "git commit --amend --no-edit";
15 fd = "${pkgs.fd}/bin/fd";
16 nix = "noglob nix"; # prevent '#' expansion
17 };
18 initContent = ''
19 eval "$(${pkgs.mcfly}/bin/mcfly init zsh)"
20 '';
21 plugins = with pkgs; [
22 {
23 name = "formarks";
24 src = fetchFromGitHub {
25 owner = "wfxr";
26 repo = "formarks";
27 rev = "8abce138218a8e6acd3c8ad2dd52550198625944";
28 sha256 = "1wr4ypv2b6a2w9qsia29mb36xf98zjzhp3bq4ix6r3cmra3xij90";
29 };
30 file = "formarks.plugin.zsh";
31 # depends on fzf
32 }
33 {
34 name = zsh-syntax-highlighting.pname;
35 src = zsh-syntax-highlighting.src;
36 }
37 {
38 name = "zsh-abbrev-alias";
39 src = fetchFromGitHub {
40 owner = "momo-lab";
41 repo = "zsh-abbrev-alias";
42 rev = "637f0b2dda6d392bf710190ee472a48a20766c07";
43 sha256 = "16saanmwpp634yc8jfdxig0ivm1gvcgpif937gbdxf0csc6vh47k";
44 };
45 file = "abbrev-alias.plugin.zsh";
46 }
47 {
48 name = zsh-autopair.pname;
49 src = zsh-autopair.src;
50 }
51 {
52 name = zsh-z.pname;
53 src = zsh-z.src;
54 }
55 ];
56 };
57
58 programs.starship = {
59 enable = true;
60 settings = {
61 format = builtins.concatStringsSep "" [
62 "$hostname"
63 "$character"
64 ];
65 right_format = builtins.concatStringsSep "" [
66 "$cmd_duration"
67 "$jobs"
68 "\${custom.jj}"
69 "$directory"
70 "\${custom.jj_branch}"
71 ];
72 add_newline = false;
73 character = {
74 success_symbol = "[\\$](bright-black)";
75 error_symbol = "[\\$](red)";
76 };
77 directory = {
78 truncation_length = 3;
79 format = " [$path]($style)[$read_only]($read_only_style)";
80 };
81 custom.jj = {
82 command = "prompt";
83 format = "$output";
84 ignore_timeout = true;
85 shell = ["${inputs.starship-jj.packages.${pkgs.system}.default}/bin/starship-jj" "--ignore-working-copy" "starship"];
86 use_stdin = false;
87 when = true;
88 };
89 custom.jj_branch = {
90 command = ''jj log --no-graph -r 'latest(::@ & (bookmarks() | remote_bookmarks()))' -T 'coalesce(bookmarks.join(", "), remote_bookmarks.join(", "))' 2>/dev/null'';
91 when = "jj root 2>/dev/null";
92 format = " [$output]($style)";
93 style = "bold yellow";
94 };
95 git_branch.disabled = true;
96 git_status.disabled = true;
97 command_timeout = 1000;
98 hostname = {
99 ssh_only = true;
100 format = "[$hostname]($style) ";
101 };
102 cmd_duration.min_time = 2000;
103 };
104 };
105
106 xdg.configFile."starship-jj/starship-jj.toml".text = ''
107 module_separator = " "
108 reset_color = false
109
110 [[module]]
111 type = "Bookmarks"
112 separator = " "
113 color = "Magenta"
114 behind_symbol = "⇡"
115 surround_with_quotes = false
116
117 [[module]]
118 type = "Commit"
119 previous_message_symbol = "⇣"
120 max_length = 24
121 show_previous_if_empty = false
122 empty_text = ""
123 surround_with_quotes = false
124 color = "Cyan"
125
126 [module.non_unique]
127 color = "Black"
128
129 [[module]]
130 type = "State"
131 separator = " "
132
133 [module.conflict]
134 disabled = false
135 text = ""
136 color = "Red"
137
138 [module.divergent]
139 disabled = false
140 text = ""
141 color = "Cyan"
142
143 [module.empty]
144 disabled = true
145 text = ""
146 color = "Yellow"
147
148 [module.immutable]
149 disabled = false
150 text = ""
151 color = "Yellow"
152
153 [module.hidden]
154 disabled = false
155 text = ""
156 color = "Yellow"
157
158 [[module]]
159 type = "Metrics"
160 template = "[{changed} {added}{removed}]"
161 hide_if_empty = true
162 color = "Magenta"
163
164 [module.changed_files]
165 prefix = ""
166 suffix = ""
167 color = "Cyan"
168
169 [module.added_lines]
170 prefix = "+"
171 suffix = ""
172 color = "Green"
173
174 [module.removed_lines]
175 prefix = "-"
176 suffix = ""
177 color = "Red"
178 '';
179
180 programs.fzf = {
181 enable = true;
182 enableZshIntegration = true;
183 };
184
185 programs.zoxide.enable = true;
186
187 # lorri > nix-direnv, but lorri is not available on macOS
188 programs.direnv = {
189 enable = true;
190 nix-direnv.enable = config.isMacOS;
191 };
192 services.lorri.enable = !config.isMacOS;
193
194 home.packages = with pkgs; [
195 mosh
196 nixd
197 ];
198}