-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.nix
executable file
·400 lines (360 loc) · 12.1 KB
/
misc.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# original configuration.nix w
{
inputs,
config,
pkgs,
lib,
user,
...
}:
{
# systemd.sysusers.enable = true;
system.etc.overlay.enable = true;
system.switch.enableNg = true;
system.switch.enable = lib.mkForce false;
system.copySystemConfiguration = false;
services.userborn.enable = true;
system.disableInstallerTools = true;
programs.less.lessopen = null;
programs.command-not-found.enable = false;
boot.enableContainers = false;
environment.defaultPackages = [ ];
documentation.info.enable = false;
systemd.services.nix-daemon.serviceConfig = {
LimitNOFILE = lib.mkForce 500000000;
Environment = [ "TMPDIR=/var/tmp/nix-daemon" ];
};
# systemd.oomd.enable = lib.mkForce false;
# srv.earlyoom.enable = true;
environment.systemPackages = [
pkgs.eza
];
boot.tmp.useTmpfs = true;
# powerManagement.powertop.enable = true;
nix = {
package = pkgs.nixVersions.stable;
channel.enable = false;
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
settings = {
system-features = [
"nixos-test"
"benchmark"
"big-parallel"
"kvm"
] ++ [ "gccarch-znver3" ];
flake-registry = "";
nix-path = [ "nixpkgs=${pkgs.path}" ];
keep-outputs = true;
keep-derivations = true;
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
# "cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA="
"nur-pkgs.cachix.org-1:PAvPHVwmEBklQPwyNZfy4VQqQjzVIaFOkYYnmnKco78="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="
"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
"anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s="
"ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI="
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
"colmena.cachix.org-1:7BzpDnjjH8ki2CT3f6GdOk7QAzPOl+1t3LvTLXqYcSg="
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE="
"nyx.chaotic.cx-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
"chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
# "cache.nyaw.xyz:wXLX+Wtj9giC/+hybqOEJ4FSZIOgOyk8Q6HJxxcZqKY="
];
extra-substituters = [ "https://cache.lix.systems" ];
substituters =
(map (n: "https://${n}.cachix.org") [
"nix-community"
"nur-pkgs"
"hyprland"
"helix"
"nixpkgs-wayland"
"anyrun"
"ezkea"
"devenv"
"colmena"
"cosmic"
])
++ [
"https://cache.nixos.org"
"https://cache.garnix.io"
"https://nyx.chaotic.cx"
# "https://cache.nyaw.xyz"
# "https://cache.ngi0.nixos.org"
# "https://mirror.sjtu.edu.cn/nix-channels/store"
];
auto-optimise-store = true;
experimental-features = [
"nix-command"
"flakes"
"auto-allocate-uids"
"cgroups"
"recursive-nix"
"ca-derivations"
];
auto-allocate-uids = true;
use-cgroups = true;
trusted-users = [
"root"
"${user}"
];
# Avoid disk full
max-free = lib.mkDefault (1000 * 1000 * 1000);
min-free = lib.mkDefault (128 * 1000 * 1000);
builders-use-substitutes = true;
allow-import-from-derivation = true;
};
daemonCPUSchedPolicy = lib.mkDefault "batch";
daemonIOSchedClass = lib.mkDefault "idle";
daemonIOSchedPriority = lib.mkDefault 7;
extraOptions = ''
!include ${config.age.secrets.gh-token.path}
'';
};
time.timeZone = "Asia/Singapore";
console = {
# font = "LatArCyrHeb-16";
keyMap = "us";
};
security = {
pki.certificateFiles = [ "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
sudo.extraConfig = ''
Defaults lecture="never"
'';
polkit.enable = true;
};
services = {
# bpftune.enable = true;
chrony.enable = true;
journald.extraConfig = ''
SystemMaxUse=1G
'';
dbus.implementation = "broker";
};
documentation = {
enable = false;
nixos.enable = false;
man.enable = false;
};
systemd.tmpfiles.rules = [
"C /var/cache/tuigreet/lastuser - - - - ${pkgs.writeText "lastuser" "${user}"}"
"d /var/tmp/nix-daemon 0755 root root -"
"d /var/lib/ssh 0755 root root -"
"L /home/${user}/.nix-profile - - - - /home/${user}/.local/state/nix/profiles/profile"
"L /home/${user}/.blerc - - - - ${pkgs.writeText "blerc" ''
bleopt term_true_colors=none
bleopt prompt_ruler=empty-line
ble-face -s command_builtin_dot fg=yellow,bold
ble-face -s command_builtin fg=yellow
ble-face -s filename_directory underline,fg=magenta
ble-face -s filename_directory_sticky underline,fg=white,bg=magenta
ble-face -s command_function fg=blue
function ble/prompt/backslash:my/starship-right {
local right
ble/util/assign right '${pkgs.starship}/bin/starship prompt --right'
ble/prompt/process-prompt-string "$right"
}
bleopt prompt_rps1="\n\n\q{my/starship-right}"
bleopt prompt_ps1_final="\033[1m=>\033[0m "
bleopt prompt_rps1_transient="same-dir"
''}"
];
i18n.defaultLocale = "en_GB.UTF-8";
environment.etc = {
"NIXOS".text = "";
"machine-id".text = "b08dfa6083e7567a1921a715000001fb\n";
"sbctl/sbctl.conf".text = ''
keydir: /var/lib/sbctl/keys
guid: /var/lib/sbctl/GUID
files_db: /var/lib/sbctl/files.json
bundles_db: /var/lib/sbctl/bundles.json
landlock: true
db_additions:
- microsoft
keys:
pk:
privkey: /var/lib/sbctl/keys/PK/PK.key
pubkey: /var/lib/sbctl/keys/PK/PK.pem
type: file
kek:
privkey: /var/lib/sbctl/keys/KEK/KEK.key
pubkey: /var/lib/sbctl/keys/KEK/KEK.pem
type: file
db:
privkey: /var/lib/sbctl/keys/db/db.key
pubkey: /var/lib/sbctl/keys/db/db.pem
type: file
'';
};
programs = {
bash = {
blesh.enable = true;
};
fish = {
enable = true;
shellAliases =
{
j = "just";
ls = "eza --icons=auto --hyperlink --color=always --color-scale=all --color-scale-mode=gradient --git --git-repos";
la = "eza --icons=auto --hyperlink --color=always --color-scale=all --color-scale-mode=gradient --git --git-repos -la";
l = "eza --icons=auto --hyperlink --color=always --color-scale=all --color-scale-mode=gradient --git --git-repos -lh";
nd = "cd /home/${user}/Src/nixos";
bl = "cd /home/${user}/Src/blog.nyaw.xyz";
swc = "sudo nixos-rebuild switch --flake /home/${user}/Src/nixos";
#--log-format internal-json -v 2>&1 | nom --json";
daso = "sudo";
daos = "sudo";
off = "poweroff";
mg = "kitty +kitten hyperlinked_grep --smart-case $argv .";
kls = "lsd --icon never --hyperlink auto";
lks = "lsd --icon never --hyperlink auto";
g = "lazygit";
"cd.." = "cd ..";
up = "nix flake update --commit-lock-file /etc/nixos && swc";
fp = "fish --private";
e = "exit";
rp = "rustplayer";
y = "yazi";
i = "kitty +kitten icat";
".." = "cd ..";
"。。" = "cd ..";
"..." = "cd ../..";
"。。。" = "cd ../..";
"...." = "cd ../../..";
"。。。。" = "cd ../../..";
}
// lib.genAttrs [
"rha"
"lsa"
"tcs"
"ubt"
"rka"
"dgs"
"rt"
] (n: "ssh ${n} -t fish");
shellInit = ''
fish_vi_key_bindings
set -g direnv_fish_mode eval_on_arrow
set -U fish_greeting
set fish_color_normal normal
set fish_color_command blue
set fish_color_quote yellow
set fish_color_redirection cyan --bold
set fish_color_end green
set fish_color_error brred
set fish_color_param cyan
set fish_color_comment red
set fish_color_match --background=brblue
set fish_color_selection white --bold --background=brblack
set fish_color_search_match bryellow --background=brblack
set fish_color_history_current --bold
set fish_color_operator brcyan
set fish_color_escape brcyan
set fish_color_cwd green
set fish_color_cwd_root red
set fish_color_valid_path --underline
set fish_color_autosuggestion white
set fish_color_user brgreen
set fish_color_host normal
set fish_color_cancel --reverse
set fish_pager_color_prefix normal --bold --underline
set fish_pager_color_progress brwhite --background=cyan
set fish_pager_color_completion normal
set fish_pager_color_description B3A06D --italics
set fish_pager_color_selected_background --reverse
set fish_cursor_default block blink
set fish_cursor_insert line blink
set fish_cursor_replace_one underscore blink
if test -z "$SSH_AUTH_SOCK" -a -n "$XDG_RUNTIME_DIR"
set -x SSH_AUTH_SOCK "$XDG_RUNTIME_DIR/ssh-agent"
end
'';
interactiveShellInit = ''
# Need to declare here, since something buggy.
# For foot `jump between prompt` function
function mark_prompt_start --on-event fish_prompt
echo -en "\e]133;A\e\\"
end
function fish_user_key_bindings
for mode in insert default visual
bind -M $mode \cf forward-char
end
end
'';
};
starship = {
enable = true;
settings = {
add_newline = false;
scan_timeout = 10;
command_timeout = 1000;
format = "$username$hostname$directory$git_branch$git_commit$git_status$nix_shell$cmd_duration$line_break$python$character";
directory.style = "blue";
character = {
success_symbol = "[>](white)";
error_symbol = "[>](red)";
vicmd_symbol = "[<](green)";
vimcmd_replace_one_symbol = "[<](bold purple)";
vimcmd_replace_symbol = "[<](bold purple)";
vimcmd_visual_symbol = "[<](bold yellow)";
};
hostname = {
ssh_only = true;
format = "[$hostname]($style) ";
style = "#91b493";
};
git_branch = {
format = "[$branch]($style) ";
style = "#F17C67";
};
git_commit = {
format = "[$hash]($style) ";
style = "#c8adc4";
only_detached = false;
tag_disabled = true;
};
git_status = {
format = "[[(*$conflicted$untracked$modified$staged$renamed$deleted)](218) ($ahead_behind$stashed)]($style) ";
style = "cyan";
conflicted = "";
untracked = "";
modified = "";
staged = "";
renamed = "";
deleted = "";
stashed = "≡";
};
git_state = {
format = "\([$state( $progress_current/$progress_total)]($style)\) ";
style = "bright-black";
};
directory = {
truncation_length = 5;
format = "[$path]($style) ";
};
cmd_duration = {
format = "[$duration]($style)";
style = "yellow";
};
python = {
format = "[$virtualenv]($style)";
style = "bright-black";
};
time = {
disabled = false;
format = "$time($style) ";
time_format = "%T";
style = "bold yellow";
utc_time_offset = "-5";
};
nix_shell = {
format = "[$symbol$state( \($name\))]($style) ";
};
};
};
};
}