-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathflake.nix
More file actions
466 lines (422 loc) · 12.9 KB
/
flake.nix
File metadata and controls
466 lines (422 loc) · 12.9 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
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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
{
description = "Neovim config";
inputs = {
mnw.url = "github:Gerg-L/mnw";
blamer-nvim-src.url = "github:psjay/blamer.nvim";
blamer-nvim-src.flake = false;
colorful-winsep-nvim-src = {
url = "github:nvim-zh/colorful-winsep.nvim";
flake = false;
};
lze-flk = {
url = "github:BirdeeHub/lze";
};
rust-owl = {
url = "github:mrcjkb/rustowl-flake";
};
lzextras-flk = {
url = "github:BirdeeHub/lzextras";
};
symbols-nvim-src = {
url = "github:oskarrrrrrr/symbols.nvim";
flake = false;
};
coqtail-src = {
url = "github:whonore/Coqtail";
flake = false;
};
neovim-nightly-overlay = {
url = "github:nix-community/neovim-nightly-overlay";
inputs.nixpkgs.follows = "nixpkgs";
flake = true;
};
ghostty-nvim-src = {
url = "github:isak102/ghostty.nvim";
flake = false;
};
claudecode-nvim-src = {
url = "github:coder/claudecode.nvim";
flake = false;
};
gitlinker-nvim-src = {
url = "github:linrongbin16/gitlinker.nvim";
flake = false;
};
ferris-nvim-src = {
url = "github:vxpm/ferris.nvim";
flake = false;
};
typst-vim-src = {
url = "github:kaarmu/typst.vim";
flake = false;
};
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs.url = "github:NixOS/nixpkgs/master";
vim-circom-syntax-src = {
url = "github:iden3/vim-circom-syntax";
flake = false;
};
vim-illuminate-src = {
url = "github:RRethy/vim-illuminate";
flake = false;
};
nil = {
url = "github:oxalica/nil";
inputs.nixpkgs.follows = "nixpkgs";
};
telescope-live-grep-args-src = {
url = "github:nvim-telescope/telescope-live-grep-args.nvim";
flake = false;
};
dracula-nvim = {
url = "github:Mofiqul/dracula.nvim";
flake = false;
};
gruvbox-nvim-src = {
url = "github:ellisonleao/gruvbox.nvim";
flake = false;
};
comment-nvim-src = {
url = "github:numToStr/Comment.nvim";
flake = false;
};
telescope-ui-select-src = {
url = "github:nvim-telescope/telescope-ui-select.nvim";
flake = false;
};
fidget-src = {
url = "github:j-hui/fidget.nvim/legacy";
flake = false;
};
which-key-src = {
url = "github:folke/which-key.nvim?ref=bd4411a2ed4dd8bb69c125e339d837028a6eea71";
flake = false;
};
colorizer-src = {
url = "github:powerman/vim-plugin-AnsiEsc";
flake = false;
};
nvim-ufo-src = {
url = "github:kevinhwang91/nvim-ufo";
flake = false;
};
nvim-async-src = {
url = "github:kevinhwang91/promise-async";
flake = false;
};
nvim-dap-src = {
url = "github:mfussenegger/nvim-dap";
flake = false;
};
nvim-dap-ui-src = {
url = "github:rcarriga/nvim-dap-ui";
flake = false;
};
nvim-dap-virtual-text-src = {
url = "github:theHamsta/nvim-dap-virtual-text";
flake = false;
};
telescope-dap-nvim-src = {
url = "github:nvim-telescope/telescope-dap.nvim";
flake = false;
};
coq-lsp-nvim-src = {
url = "github:DieracDelta/coq-lsp.nvim";
flake = false;
};
node-type-nvim-src = {
url = "github:roobert/node-type.nvim";
flake = false;
};
floating-input-src = {
url = "github:liangxianzhe/floating-input.nvim";
flake = false;
};
ts-node-action-src = {
url = "github:CKolkey/ts-node-action";
flake = false;
};
nvim-treesitter-src = {
url = "github:nvim-treesitter/nvim-treesitter";
flake = false;
};
telescope-dapzzzz-src = {
url = "github:HUAHUAI23/telescope-dapzzzz";
flake = false;
};
};
outputs =
inputs@{
self,
nixpkgs,
neovim-nightly-overlay,
lze-flk,
lzextras-flk,
rust-owl,
mnw,
...
}:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems f;
mkNeovim = { system, isMinimal ? false }:
let
# Common overlays used by all systems
commonOverlays = [
(import ./plugins.nix inputs)
lze-flk.overlays.default
lzextras-flk.overlays.default
];
pkgs =
if system == "x86_64-linux" then
# Full config with znver3 useflags
(import nixpkgs {
localSystem = {
inherit system;
gcc.arch = "znver3";
gcc.mtune = "znver3";
};
crossSystem = {
inherit system;
gcc.arch = "znver3";
gcc.mtune = "znver3";
};
overlays = commonOverlays ++ [
(prev: final: {
stdenvnew = prev.stdenvAdapters.addAttrsToDerivation {
NIX_CFLAGS_COMPILE = "-flto";
} prev.stdenv;
nil = inputs.nil.packages.${system}.nil;
})
];
})
else if system == "aarch64-linux" then
# Minimal config for ARM Linux - no arch tuning, space-optimized
(import nixpkgs {
inherit system;
overlays = commonOverlays ++ [
(prev: final: {
nil = inputs.nil.packages.${system}.nil;
})
];
})
else
# aarch64-darwin: Full config, no useflags
(import nixpkgs {
localSystem = {
inherit system;
gcc.arch = "-march=apple-m1";
gcc.mtune = "-march=apple-m1";
};
crossSystem = {
inherit system;
gcc.arch = "-march=apple-m1";
gcc.mtune = "-march=apple-m1";
};
overlays = commonOverlays ++ [
(prev: final: {
nil = inputs.nil.packages.${system}.nil;
nodejs = final.nodejs.overrideAttrs (oldAttrs: {
doCheck = false;
});
})
];
});
# Build-time theme variant based on target system
# darwin = green forest theme, arm = red crimson theme, default = original gruvbox
themeVariant =
if nixpkgs.lib.hasInfix "darwin" system then "darwin"
else if system == "aarch64-linux" then "arm"
else "default";
# Write theme config to a Lua file that sets a global variable for aesthetics.lua
themeConfigFile = pkgs.writeText "gruvbox-theme-variant.lua" ''
-- Set by Nix at build time based on target system
vim.g.gruvbox_theme_variant = "${themeVariant}"
'';
# plugin, config file
requiredPluginList = with pkgs; [
# lazy loading
vimPlugins.lze
vimPlugins.lzextras
# essentials
which-key
# aesthetics
gruvbox-nvim
vimPlugins.lualine-nvim
vimPlugins.tabline-nvim
vimPlugins.nvim-web-devicons
# misc
vimPlugins.nui-nvim
# lsp
vimPlugins.nvim-nio
vimPlugins.rust-vim
typst-vim
vimPlugins.lsp_signature-nvim
vimPlugins.nvim-cmp
vimPlugins.cmp-path
vimPlugins.cmp-buffer
vimPlugins.cmp-cmdline
vimPlugins.cmp-nvim-lsp
vimPlugins.lspkind-nvim
vimPlugins.plenary-nvim
vimPlugins.popup-nvim
# treesitter
nvim-async
] ++ pkgs.lib.optionals (!isMinimal) [
# Full builds only - excluded from aarch64-linux minimal
vimPlugins.image-nvim # requires imagemagick
vimPlugins.vim-ormolu # haskell formatter
];
luaModules = [
"essentials"
"aesthetics"
"lsp"
"completion"
];
luaLazyModules = [
"rustaceanvim"
"ferris"
"parinfer"
"ghostty"
"lsp_servers"
"typescript"
"crates"
"telescope"
"gitlinker"
"git"
"gitsigns"
"treesitter"
"autopairs"
"misc"
"ui"
"formatting"
] ++ pkgs.lib.optionals (!isMinimal) [
# Full builds only - excluded from aarch64-linux minimal
"haskell-tools-nvim"
"lean"
"claudecode"
"coq"
];
luaRequire' = module: builtins.toString ./required_lua_modules + "/${module}.lua";
luaLazyRequire' = module: builtins.toString ./lazy_lua_modules + "/${module}.lua";
myNeovim' = mnw.lib.wrap pkgs {
providers = {
ruby.enable = !isMinimal;
python3.enable = !isMinimal;
nodeJs.enable = !isMinimal;
perl.enable = !isMinimal;
};
extraBinPath =
builtins.attrValues {
inherit (pkgs)
nixfmt-rfc-style
ruff
ripgrep
fd
nil
vscode-langservers-extracted
stylua
shellcheck
shfmt
prettierd
just-lsp
ty
;
}
++ [ (if isMinimal then pkgs.gitMinimal else pkgs.git) ]
++ pkgs.lib.optionals (!isMinimal) [
# Full builds only - excluded from aarch64-linux minimal
pkgs.clang-tools
pkgs.terraform-ls
pkgs.lua-language-server
pkgs.myRSetup
pkgs.imagemagick
]
++ pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.inotify-tools
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.sourcekit-lsp
pkgs.swift-format
pkgs.swiftlint
];
neovim = inputs.neovim-nightly-overlay.packages.${pkgs.stdenv.system}.default;
extraLuaPackages = ps: pkgs.lib.optionals (!isMinimal) [ ps.magick ];
plugins = {
start = requiredPluginList;
opt = with pkgs; [
vimPlugins.rustaceanvim
ferris-nvim
parinfer-rust-nvim
ghostty-nvim
vimPlugins.typescript-tools-nvim
vimPlugins.crates-nvim
# telescope-nvim is pulled in as dependency of its extensions
vimPlugins.telescope-file-browser-nvim
vimPlugins.telescope-live-grep-args-nvim
telescope-ui-select
vimPlugins.telescope-zoxide
vimPlugins.yazi-nvim
gitlinker-nvim
vimPlugins.neogit
vimPlugins.gitsigns-nvim
blamer-nvim
(nvim-ufo.overrideAttrs (oa: {
doCheck = false;
}))
comment-nvim
vimPlugins.nvim-ts-autotag
vimPlugins.rainbow-delimiters-nvim
vim-illuminate
vimPlugins.surround-nvim
vimPlugins.undotree
colorizer
vimPlugins.nvim-autopairs
vimPlugins.markid
ts-node-action
colorful-winsep-nvim
fidget
vimPlugins.trouble-nvim
symbols-nvim
node-type-nvim
floating-input
vimPlugins.dressing-nvim
vimPlugins.conform-nvim
] ++ pkgs.lib.optionals (!isMinimal) [
# Full builds only - excluded from aarch64-linux minimal
vimPlugins.lean-nvim
vimPlugins.snacks-nvim
claudecode-nvim
coq-lsp-nvim
coqtail
vimPlugins.haskell-tools-nvim
];
};
luaFiles = [ themeConfigFile ] ++ map luaRequire' luaModules ++ map luaLazyRequire' luaLazyModules;
};
in
myNeovim';
in
{
defaultPackage = forAllSystems (system: mkNeovim { inherit system; isMinimal = false; });
apps = forAllSystems (system: {
default = {
type = "app";
program = "${mkNeovim { inherit system; isMinimal = false; }}/bin/nvim";
};
minimal = {
type = "app";
program = "${mkNeovim { inherit system; isMinimal = true; }}/bin/nvim";
};
});
packages = forAllSystems (system: {
default = mkNeovim { inherit system; isMinimal = false; };
neovim = mkNeovim { inherit system; isMinimal = false; };
neovim-minimal = mkNeovim { inherit system; isMinimal = true; };
});
hydraJobs.x86_64-linux = {
neovim = self.packages.x86_64-linux.neovim;
neovim-minimal = self.packages.x86_64-linux.neovim-minimal;
};
};
}