-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.nix
executable file
·429 lines (387 loc) · 13.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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# original configuration.nix w
{
inputs,
config,
pkgs,
lib,
user,
...
}:
{
system = {
# systemd.sysusers.enable = true;
switch.enableNg = true;
switch.enable = lib.mkForce false;
# apply.enable = true;
copySystemConfiguration = false;
disableInstallerTools = true;
tools.nixos-rebuild.enable = false;
};
systemd.services.systemd-networkd.serviceConfig.TimeoutStopSec = "10s";
programs = {
less.lessopen = null;
command-not-found.enable = false;
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 = false;
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) ";
};
};
};
};
boot.enableContainers = false;
environment = {
defaultPackages = [ ];
# srv.earlyoom.enable = true;
systemPackages = [
pkgs.eza
];
etc = {
"NIXOS".text = "";
"machine-id".text = "b08dfa6083e7567a1921a715000001fb\n";
"sbctl/sbctl.conf".source =
let
sbctlVar = "/var/lib/sbctl";
in
(pkgs.formats.yaml { }).generate "sbctl.conf" {
bundles_db = "${sbctlVar}/bundles.json";
db_additions = [ "microsoft" ];
files_db = "${sbctlVar}/files.json";
guid = "${sbctlVar}/GUID";
keydir = "${sbctlVar}/keys";
keys = {
db = {
privkey = "${sbctlVar}/keys/db/db.key";
pubkey = "${sbctlVar}/keys/db/db.pem";
type = "file";
};
kek = {
privkey = "${sbctlVar}/keys/KEK/KEK.key";
pubkey = "${sbctlVar}/keys/KEK/KEK.pem";
type = "file";
};
pk = {
privkey = "${sbctlVar}/keys/PK/PK.key";
pubkey = "${sbctlVar}/keys/PK/PK.pem";
type = "file";
};
};
landlock = true;
};
};
};
documentation.info.enable = false;
systemd.services.nix-daemon.serviceConfig = {
# WARNING: THIS makes nix-daemon build extremely slow
# LimitNOFILE = lib.mkForce 500000000;
Environment = [ "TMPDIR=/var/tmp/nix-daemon" ];
};
boot.tmp.useTmpfs = true;
# powerManagement.powertop.enable = true;
nix = {
package = pkgs.nixVersions.stable;
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
channel.enable = false;
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
settings = {
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="
"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
"cache.lix.systems:aBnZUw8zA7H35Cz2RyKFVs3H4PlGTLawyY5KRbvJR8o="
# "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
];
extra-substituters =
[
"https://cache.lix.systems"
]
++ (map (n: "https://${n}.cachix.org") [
"nix-community"
"helix"
"nixpkgs-wayland"
]);
substituters = [
# "https://cache.garnix.io"
];
auto-optimise-store = true;
experimental-features = [
"nix-command"
"flakes"
"auto-allocate-uids"
"cgroups"
"recursive-nix"
"ca-derivations"
# "pipe-operator"
"pipe-operators"
];
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.vaultix.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"
(pkgs.writeText "root.crt" ''
-----BEGIN CERTIFICATE-----
MIIBZTCCARegAwIBAgIUK5cIP43nYTxkSom4car51xB2fyUwBQYDK2VwMC4xETAP
BgNVBAoMCE1pbGlldWltMRkwFwYDVQQDDBBNaWxpZXVpbSBSb290IENBMCAXDTI1
MDEyNjA3MzMxN1oYDzIxMjUwMTAyMDczMzE3WjAuMREwDwYDVQQKDAhNaWxpZXVp
bTEZMBcGA1UEAwwQTWlsaWV1aW0gUm9vdCBDQTAqMAUGAytlcAMhAPeokscNudjM
ghOCxZMw0lnzVWN73e4XZQObR6Z+jW/Co0UwQzAdBgNVHQ4EFgQU2FgDKiVfEizN
YB6Uo8v+JKVo4VUwEgYDVR0TAQH/BAgwBgEB/wIBATAOBgNVHQ8BAf8EBAMCAQYw
BQYDK2VwA0EAek7DrIzml/QbQ0pvtKXtIguAu1LkS7dJEH11ywG60ZcNsSaASp4t
JnKJ63hPDuCvx1YlB6enilL3BMAs2CX2Dg==
-----END CERTIFICATE-----
'')
(pkgs.writeText "intermediate.crt" ''
-----BEGIN CERTIFICATE-----
MIIBvTCCAW+gAwIBAgIUAf5RM0UXJbedoKBU9/Y0EVmqSbkwBQYDK2VwMC4xETAP
BgNVBAoMCE1pbGlldWltMRkwFwYDVQQDDBBNaWxpZXVpbSBSb290IENBMB4XDTI1
MDIwMTE0MjEwMloXDTM1MDEzMDE0MjEwMlowODERMA8GA1UECgwITWlsaWV1aW0x
IzAhBgNVBAMMGk1pbGlldWltIEludGVybWVkaWF0ZSBDQSAwMFkwEwYHKoZIzj0C
AQYIKoZIzj0DAQcDQgAEOUhNYWn7tf0AeKajjrnbPeUtxy+gPSm6243USRSQ6UNA
Wtoqd08YLydE7mWn3GXfQK4kCvuCijHuOSfvPI5D7KNmMGQwHQYDVR0OBBYEFFLg
cYw1Qz+gD42r/EC7+Mar3UcEMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/
BAQDAgIEMB8GA1UdIwQYMBaAFNhYAyolXxIszWAelKPL/iSlaOFVMAUGAytlcANB
AGdqS2Qdxc74lngRWUTm9vzRwvVlIrw90Uas6I25XRlcxfwSp5h+CAizDqtoxEIK
4OfM5E+YRurQ9FX7BuVLYwU=
-----END CERTIFICATE-----
'')
];
# caCertificateBlacklist = [
# "CNNIC ROOT"
# "CNNIC SSL"
# "China Internet Network Information Center EV Certificates Root"
# "WoSign"
# "WoSign China"
# "CA WoSign ECC Root"
# "Certification Authority of WoSign G2"
# ];
};
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";
}