-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.nix
More file actions
391 lines (346 loc) · 10.4 KB
/
home.nix
File metadata and controls
391 lines (346 loc) · 10.4 KB
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
/**
_unique_ entrypoint for home-manager configurations
... across _all_ platforms
*/
{ pkgs, lib, config, ... }:
let
inherit (pkgs.stdenv.hostPlatform)
isDarwin
isLinux;
packages = with pkgs; {
/* some packages are better installed via system pacman, e.g.
- zsh: better be under root to be set the default shell
- neovim: as the editor for sudoedit
- nix: the daemon
these can be managed with `system-manager` once it stabilizes.
*/
os.basic = [
## <nixpkgs> pkgs/stdenv/generic/common-path.nix
coreutils util-linux findutils diffutils
gnused gnugrep gnumake
which tree file procps less
] ++ lib.optionals isLinux [
iputils
];
nix.basic = [
cachix
nix-tree
nix-diff
] ++ lib.optionals isLinux [
config.nix.package # manage itself ## daemon managed by root
];
nix.dev = [
nil # language server
nixpkgs-fmt # the unofficial formatter
nixfmt # the official formatter
nurl # generate fetcher call
nix-init # generate package
nix-update
nix-output-monitor
nix-flake-tree # ./nixpkgs-config/niz/scripts/flake-tree.py
nixpkgs-pr-checker # ./nixpkgs-config/niz/scripts/pr-checker.sh
nixpkgs-hammering
nixpkgs-review
nixd # future lsp ## not stable # needs llvmPackages.llvm.lib
# hydra-check # now managed in `bryango/flakes`
# nvd # version diff
] ++ lib.optionals isLinux [
system-manager # to be stabilized
];
cli.basic = [
neovim
jq
bat
fzf
ripgrep
byobu-with-tmux
diff-so-fancy
shellcheck
git
lazygit
chezmoi
age
fd
progress
tldr
zoxide
lsof
wget
trash-cli
# git-branchless # moved to local dev build
dust
bottom
jujutsu-unstable
faketty
procs
wol
sshuttle
openssh # need to unset SSH_AUTH_SOCK, maybe
# trashy # better, but its zsh completion is broken
(if isDarwin then (binaryFallback "ifconfig" inetutils) else inetutils)
(if isLinux then (binaryFallback "aria2c" aria2) else aria2)
(writeShellScriptBin "proxychains" ''
if command -v proxychains4 &>/dev/null; then
exec proxychains4 "$@"
fi
if command -v env-proxy &>/dev/null; then
exec env-proxy "$@"
fi
>&2 echo could not find "proxychains" or "env-proxy"
exit 1
'')
] ++ lib.optionals isLinux [
proxychains
# (binaryFallback "proxychains4" proxychains-ng)
];
cli.dev = [
aichat
geminicommit
mosh
difftastic
jc
rustc cargo clippy
(lib.setPrio 3 rustup)
cargo-binstall # then `cargo binstall cargo-quickinstall`
cargo-tarpaulin # show test coverage
cargo-nextest # better test runner
nodejs # required by coc.nvim
watchman # as git fsmonitor
# mise # dev runtime manager
# evcxr # too heavy, instead `cargo quickinstall evcxr_repl`
# getoptions # shell argument parser
# diffoscopeMinimal # too heavy, use distro package instead
# devbox # cool but I am mostly using vanilla nix flake
] ++ lib.optionals isLinux [
mold # linker for non-nix projects; for nix, use `mold-wrapped`
# ... currently broken on darwin
];
cli.app = [
gh
circumflex # hacker news terminal
tectonic
(writeShellScriptBin "biber-for-tectonic" ''exec ${lib.getExe tectonic.biber} "$@"'')
inetutils # telnet
dufs # file server
(if isLinux then miktex else texliveSmall.withPackages (ps: with ps; [
texdoc
enumitem
doublestroke
todonotes
nowidow
helvetic
comment
uri
tikz-cd
]))
hunspellDicts.en_US-large
hyphenDicts.en_US
] ++ lib.optionals isLinux [
fuse-overlayfs
uxplay # airplay server
] ++ lib.optionals isDarwin [
nightlight
];
cli.python = let
inherit python3Packages;
/* <nixpkgs> pkgs/top-level/aliases.nix
pythonPackages = python.pkgs;
python = python2;
*/
in [
### do NOT expose python itself for safety reasons
python3Packages.ipython
python3Packages.jedi-language-server
ruff # exposes `ruff`
poetry
pipx
];
gui.app = [
djview
(gimp2-with-plugins.override {
plugins = # with gimpPlugins;
[
# # broken since removal of enum34
# # https://github.com/NixOS/nixpkgs/pull/389263
# resynthesizer
];
})
zed-editor
texstudio-lazy_resize # fork from nixpkgs-config
## vscode dummy:
(binaryFallback "code" (writeShellScriptBin "code" ''echo "$@"''))
] ++ lib.optionals isLinux [
xorg.xinput
remmina
pulsar # atom fork
nixgl.nixGLIntel
nixgl.nixVulkanIntel
(writeShellApplication {
name = "zeditor";
runtimeInputs = [
zed-editor
nixgl.nixVulkanIntel
];
text = ''exec -a zeditor nixVulkanIntel zeditor "$@"'';
meta.priority = (zed-editor.meta.priority or 5) - 1;
# override the original zed binary
})
] ++ lib.optionals isDarwin [
darwin-apps # from ./overlay.nix
];
};
in {
imports = [
./modules/direnv-exec-apps
./modules/redshift-many
./modules/v2ray-ctrl
./modules/nixpkgs-helpers
./modules/flake-channels.nix
./modules/home-setup.nix
## ^ process & pass home attrs with basic setup
];
home.packages = with packages;
os.basic ++
nix.basic ++
nix.dev ++
cli.basic ++
cli.dev ++
cli.app ++
cli.python ++
gui.app ++
[
## It is sometimes useful to fine-tune packages, for example, by applying
## overrides. You can do that directly here, just don't forget the
## parentheses:
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
## You can also create simple shell scripts directly inside your
## configuration. For example, this adds a command 'my-hello' to your
## environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
];
programs.v2ray-ctrl = {
# enable = false;
outbounds = "dal4";
# routings =
# "private-direct,cn-direct,tencent-direct,ms-transit,zoom-transit";
};
programs.direnv-exec-apps = {
apps = [
"pdflatex"
"xelatex"
"biber"
"bibtex"
"texdoc"
];
};
# disabled: not working for the moment
# probably due to xorg -> wayland switch
services.redshift-many = lib.optionalAttrs /* isLinux */ false {
redshift = {
settings.randr.crtc = 0;
temperature.always = 3200;
};
redshift-ext = {
settings.randr.crtc = 1;
temperature.always = 3600;
# temperature.always = 4800;
};
};
programs.xrandr-brightness = {
output = "DP-1";
# output = "HDMI-1";
};
programs.nixpkgs-helpers = {
viewer = "echo code --goto";
# flakeref = "nixpkgs";
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
# stdlib = "";
};
programs.man = {
enable = true; ## `disable` to use system manpage
};
disabledModules = [
## https://github.com/nix-community/home-manager/issues/2333
## https://github.com/nix-community/home-manager/blob/master/modules/config/i18n.nix
## use system locale; see `sessionVariables`
"config/i18n.nix"
];
## nix settings
## `nix.package` set in `flake.nix` (must set for `nix.settings` and stuff)
nix.settings = {
max-jobs = "auto";
fallback = true;
## do _not_ cache negative substituter hits
narinfo-cache-negative-ttl = 0;
## need to set `trusted-users = @wheel` in `/etc/nix/nix.conf`
# tarball-ttl = 4294967295;
auto-optimise-store = true;
extra-substituters = [ ## with `?priority`
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store?priority=20"
# "https://mirror.sjtu.edu.cn/nix-channels/store?priority=20"
## cachix use nix-community -O .
"https://chezbryan.cachix.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"chezbryan.cachix.org-1:4n1STyrAtSfRth4sbgUCKfgjtgR8yIy40jIV829Lfow="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
home.file = {
## Building this configuration will create a copy of 'dotfiles/screenrc' in
## the Nix store. Activating the configuration will then make '~/.screenrc' a
## symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;
## You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
# You can also manage environment variables but you will have to manually
# source
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/bryan/etc/profile.d/hm-session-vars.sh
#
# if you don't want to manage your shell through Home Manager.
home.sessionVariables = {
## use system locale; see `disabledModules`
LOCALE_ARCHIVE = "/usr/lib/locale/locale-archive";
# EDITOR = "nvim";
# NIX_PATH = "nixpkgs=${pkgs.outPath}";
};
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "22.11"; # Please read the comment before changing.
i18n.inputMethod = lib.optionalAttrs isLinux {
enable = true;
type = "fcitx5";
# one might also need to install native system integrations, e.g.
# sudo pacman -S fcitx5-gtk
fcitx5 = with pkgs; {
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/i18n/input-method/fcitx5.nix
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/inputmethods/fcitx5/with-addons.nix
fcitx5-with-addons = qt6Packages.fcitx5-with-addons.override {
fcitx5-configtool = fcitx5-configtool-no-kcm; # defined in nixpkgs-config
};
addons = with qt6Packages; [
fcitx5-chinese-addons
];
};
};
}