forked from BirdeeHub/nixCats-nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
518 lines (484 loc) · 17.6 KB
/
flake.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
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
# Copyright (c) 2023 BirdeeHub
# Licensed under the MIT license
{
description = "A Lua-natic's neovim flake, with extra cats! nixCats!";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
# see :help nixCats.flake.inputs
# If you want your plugin to be loaded by the standard overlay,
# i.e. if it wasnt on nixpkgs, but doesnt have an extra build step.
# Then you should name it "plugins-something"
# If you wish to define a custom build step not handled by nixpkgs,
# then you should name it in a different format, and deal with that in the
# overlay defined for custom builds in the overlays directory.
# for specific tags, branches and commits, see:
# https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake.html#examples
"plugins-hlargs" = {
url = "github:m-demare/hlargs.nvim";
flake = false;
};
# neovim = {
# url = "github:neovim/neovim";
# flake = false;
# };
};
# see :help nixCats.flake.outputs
outputs = { self, nixpkgs, flake-utils, ... }@inputs: let
utils = (import ./nix/utils).utils;
luaPath = "${./.}";
forEachSystem = flake-utils.lib.eachSystem flake-utils.lib.allSystems;
# the following extra_pkg_config contains any values
# which you want to pass to the config set of nixpkgs
# import nixpkgs { config = extra_pkg_config; inherit system; }
# will not apply to module imports
# as that will have your system values
extra_pkg_config = {
# allowUnfree = true;
};
# sometimes our overlays require a ${system} to access the overlay.
# management of this variable is one of the harder parts of using flakes.
# so I have done it here in an interesting way to keep it out of the way.
# First, we will define just our overlays per system.
# later we will pass them into the builder, and the resulting pkgs set
# will get passed to the categoryDefinitions and packageDefinitions
# which follow this section.
# this allows you to use ${pkgs.system} whenever you want in those sections
# without fear.
system_resolved = forEachSystem (system: let
# see :help nixCats.flake.outputs.overlays
dependencyOverlays = (import ./overlays inputs) ++ [
# This overlay grabs all the inputs named in the format
# `plugins-<pluginName>`
# Once we add this overlay to our nixpkgs, we are able to
# use `pkgs.neovimPlugins`, which is a set of our plugins.
(utils.standardPluginOverlay inputs)
# add any flake overlays here.
];
# these overlays will be wrapped with ${system}
# and we will call the same flake-utils function
# later on to access them.
in { inherit dependencyOverlays; });
inherit (system_resolved) dependencyOverlays;
# see :help nixCats.flake.outputs.categories
# and
# :help nixCats.flake.outputs.categoryDefinitions.scheme
categoryDefinitions = { pkgs, settings, categories, name, ... }@packageDef: {
# to define and use a new category, simply add a new list to a set here,
# and later, you will include categoryname = true; in the set you
# provide when you build the package using this builder function.
# see :help nixCats.flake.outputs.packageDefinitions for info on that section.
# propagatedBuildInputs:
# this section is for dependencies that should be available
# at BUILD TIME for plugins. WILL NOT be available to PATH
# However, they WILL be available to the shell
# and neovim path when using nix develop
propagatedBuildInputs = {
generalBuildInputs = with pkgs; [
];
};
# lspsAndRuntimeDeps:
# this section is for dependencies that should be available
# at RUN TIME for plugins. Will be available to PATH within neovim terminal
# this includes LSPs
lspsAndRuntimeDeps = {
general = with pkgs; [
universal-ctags
ripgrep
fd
zig # here as a c compiler
];
csharpdev = with pkgs; [
omnisharp-roslyn # lsp
netcoredbg # debugger
uncrustify # formatter
];
zigdev = with pkgs; [
zls # lsp
lldb # debugger
];
neonixdev = {
# also you can do this.
inherit (pkgs) nix-doc nil lua-language-server nixd alejandra;
# nix-doc tags will make your tags much better in nix
# but only if you have nil as well for some reason
};
};
# This is for plugins that will load at startup without using packadd:
startupPlugins = {
debug = with pkgs.vimPlugins; [
nvim-dap
nvim-dap-ui
nvim-dap-virtual-text
];
neonixdev = with pkgs.vimPlugins; [
neodev-nvim
neoconf-nvim
];
# yes these category names are arbitrary
markdown = with pkgs.vimPlugins; [
markdown-preview-nvim
];
lazy = with pkgs.vimPlugins; [
lazy-nvim
];
general = {
gitPlugins = with pkgs.neovimPlugins; [
hlargs
];
vimPlugins = {
# you can make a subcategory
cmp = with pkgs.vimPlugins; [
# cmp stuff
nvim-cmp
luasnip
friendly-snippets
cmp_luasnip
cmp-buffer
cmp-path
cmp-nvim-lua
cmp-nvim-lsp
cmp-cmdline
cmp-nvim-lsp-signature-help
cmp-cmdline-history
lspkind-nvim
];
general = with pkgs.vimPlugins; [
telescope-fzf-native-nvim
plenary-nvim
telescope-nvim
# treesitter
nvim-treesitter-textobjects
nvim-treesitter.withAllGrammars
# This is for if you only want some of the grammars
# (nvim-treesitter.withPlugins (
# plugins: with plugins; [
# nix
# lua
# ]
# ))
# other
nvim-lspconfig
fidget-nvim
lualine-nvim
gitsigns-nvim
which-key-nvim
comment-nvim
vim-sleuth
vim-fugitive
vim-rhubarb
vim-repeat
undotree
nvim-surround
indent-blankline-nvim
nvim-web-devicons
eyeliner-nvim
toggleterm-nvim
neo-tree-nvim
statuscol-nvim
nvim-osc52
nvim-ufo
conform-nvim
diffview-nvim
];
};
};
# You can retreive information from the
# packageDefinitions of the package this was packaged with.
# :help nixCats.flake.outputs.categoryDefinitions.scheme
themer = with pkgs.vimPlugins;
(builtins.getAttr categories.colorscheme {
# Theme switcher without creating a new category
"onedark" = onedark-nvim;
"catppuccin" = catppuccin-nvim;
"catppuccin-mocha" = catppuccin-nvim;
"tokyonight" = tokyonight-nvim;
"tokyonight-day" = tokyonight-nvim;
}
);
# This is obviously a fairly basic usecase for this, but still nice.
# Checking packageDefinitions also has the bonus
# of being able to be easily set by importing flakes.
};
# not loaded automatically at startup.
# use with packadd and an autocommand in config to achieve lazy loading
optionalPlugins = {
custom = with pkgs.nixCatsBuilds; [ ];
gitPlugins = with pkgs.neovimPlugins; [ ];
general = with pkgs.vimPlugins; [ ];
};
# environmentVariables:
# this section is for environmentVariables that should be available
# at RUN TIME for plugins. Will be available to path within neovim terminal
environmentVariables = {
test = {
subtest1 = {
CATTESTVAR = "It worked!";
};
subtest2 = {
CATTESTVAR3 = "It didn't work!";
};
};
};
# If you know what these are, you can provide custom ones by category here.
# If you dont, check this link out:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/make-wrapper.sh
extraWrapperArgs = {
test = [
'' --set CATTESTVAR2 "It worked again!"''
];
};
# lists of the functions you would have passed to
# python.withPackages or lua.withPackages
extraPythonPackages = {
test = (_:[]);
};
extraPython3Packages = {
test = (_:[]);
};
extraLuaPackages = {
test = [ (_:[]) ];
};
};
# packageDefinitions:
# Now build a package with specific categories from above
# All categories you wish to include must be marked true,
# but false may be omitted.
# This entire set is also passed to nixCats for querying within the lua.
# It is directly translated to a Lua table, and a get function is defined.
# The get function is to prevent errors when querying subcategories.
# see :help nixCats.flake.outputs.packageDefinitions
packageDefinitions = {
# these also recieve our pkgs variable
nixCats = { pkgs, ... }@misc: {
# see :help nixCats.flake.outputs.settings
settings = {
# will check for config in the store rather than .config
wrapRc = true;
configDirName = "nixCats-nvim";
aliases = [ "vim" "vimcat" ];
# nvimSRC = inputs.neovim;
};
# see :help nixCats.flake.outputs.packageDefinitions
categories = {
generalBuildInputs = true;
markdown = true;
general.vimPlugins = true;
general.gitPlugins = true;
custom = true;
neonixdev = true;
test = {
subtest1 = true;
};
debug = false;
# this does not have an associated category of plugins,
# but lua can still check for it
lspDebugMode = false;
# by default, we dont want lazy.nvim
# we could omit this for the same effect
lazy = false;
# you could also pass something else:
themer = true;
colorscheme = "onedark";
theBestCat = "says meow!!";
theWorstCat = {
thing'1 = [ "MEOW" "HISSS" ];
thing2 = [
{
thing3 = [ "give" "treat" ];
}
"I LOVE KEYBOARDS"
];
thing4 = "couch is for scratching";
};
# see :help nixCats
};
};
nixCatsCsharp = { pkgs, ... }@misc: {
# see :help nixCats.flake.outputs.settings
settings = {
# will check for config in the store rather than .config
wrapRc = true;
configDirName = "nixCats-nvim";
aliases = [ "vim" "vimcat" ];
# nvimSRC = inputs.neovim;
};
# see :help nixCats.flake.outputs.packageDefinitions
categories = {
generalBuildInputs = true;
markdown = true;
general.vimPlugins = true;
general.gitPlugins = true;
custom = true;
neonixdev = true;
csharpdev = true;
test = {
subtest1 = true;
};
debug = true;
# this does not have an associated category of plugins,
# but lua can still check for it
lspDebugMode = false;
# by default, we dont want lazy.nvim
# we could omit this for the same effect
lazy = false;
# you could also pass something else:
themer = true;
colorscheme = "onedark";
theBestCat = "says meow!!";
theWorstCat = {
thing'1 = [ "MEOW" "HISSS" ];
thing2 = [
{
thing3 = [ "give" "treat" ];
}
"I LOVE KEYBOARDS"
];
thing4 = "couch is for scratching";
};
# see :help nixCats
};
};
nixCatsZig = { pkgs, ... }@misc: {
# see :help nixCats.flake.outputs.settings
settings = {
# will check for config in the store rather than .config
wrapRc = true;
configDirName = "nixCats-nvim";
aliases = [ "vim" "vimcat" ];
# nvimSRC = inputs.neovim;
};
# see :help nixCats.flake.outputs.packageDefinitions
categories = {
generalBuildInputs = true;
markdown = true;
general.vimPlugins = true;
general.gitPlugins = true;
custom = true;
neonixdev = true;
zigdev = true;
test = {
subtest1 = true;
};
debug = true;
# this does not have an associated category of plugins,
# but lua can still check for it
lspDebugMode = false;
# by default, we dont want lazy.nvim
# we could omit this for the same effect
lazy = false;
# you could also pass something else:
themer = true;
colorscheme = "onedark";
theBestCat = "says meow!!";
theWorstCat = {
thing'1 = [ "MEOW" "HISSS" ];
thing2 = [
{
thing3 = [ "give" "treat" ];
}
"I LOVE KEYBOARDS"
];
thing4 = "couch is for scratching";
};
# see :help nixCats
};
};
regularCats = { pkgs, ... }@misc: {
settings = {
# will check for config in .config rather than the store
# this is mostly useful for fast iteration while editing lua.
wrapRc = false;
# will now look for nixCats-nvim within .config and .local and others
configDirName = "nixCats-nvim";
aliases = [ "testCat" ];
};
categories = {
generalBuildInputs = true;
markdown = true;
general = true;
custom = true;
neonixdev = true;
test = true;
lspDebugMode = false;
themer = true;
colorscheme = "catppuccin";
theBestCat = "says meow!!";
theWorstCat = {
thing'1 = [ "MEOW" "HISSS" ];
thing2 = [
{
thing3 = [ "give" "treat" ];
}
"I LOVE KEYBOARDS"
];
thing4 = "couch is for scratching";
};
};
};
};
in
# In this section, the main thing you will need to do is change the default package name
# to the name of the packageDefinitions entry you wish to use as the default.
# see :help nixCats.flake.outputs.exports
forEachSystem (system: let
# get our base builder
inherit (utils) baseBuilder;
# give it everything except packageDefinitions
customPackager = baseBuilder luaPath {
# we pass in the things to make a pkgs variable to build nvim with later
inherit nixpkgs system dependencyOverlays extra_pkg_config;
# and also our categoryDefinitions
} categoryDefinitions;
# and this will be our builder! it takes a name from our packageDefinitions as an argument, and builds an nvim.
nixCatsBuilder = customPackager packageDefinitions;
# this pkgs variable is just for using utils such as pkgs.mkShell
# within this outputs set.
pkgs = import nixpkgs { inherit system; };
# The one used to build neovim is resolved inside the builder
# and is passed to our categoryDefinitions and packageDefinitions
in {
# these outputs will be wrapped with ${system} by flake-utils.lib.eachDefaultSystem
# this will make a package out of each of the packageDefinitions defined above
# and set the default package to the one named here.
packages = utils.mkPackages nixCatsBuilder packageDefinitions "nixCats";
# this will make an overlay out of each of the packageDefinitions defined above
# and set the default overlay to the one named here.
overlays = utils.mkOverlays nixCatsBuilder packageDefinitions "nixCats";
# choose your package for devShell
# and add whatever else you want in it.
devShell = pkgs.mkShell {
name = "nixCats";
packages = [ (nixCatsBuilder "nixCats") ];
inputsFrom = [ ];
shellHook = ''
'';
};
# To set just packageDefinitions from the config that calls this flake.
inherit customPackager;
}) // {
# now we can export some things that can be imported in other
# flakes, WITHOUT needing to use a system variable to do it.
# and update them into the rest of the outputs returned by the
# eachDefaultSystem function.
# these outputs will be NOT wrapped with ${system}
# we also export a nixos module to allow configuration from configuration.nix
nixosModules.default = utils.mkNixosModules {
defaultPackageName = "nixCats";
inherit dependencyOverlays luaPath
categoryDefinitions packageDefinitions nixpkgs;
};
# and the same for home manager
homeModule = utils.mkHomeModules {
defaultPackageName = "nixCats";
inherit dependencyOverlays luaPath
categoryDefinitions packageDefinitions nixpkgs;
};
inherit utils categoryDefinitions packageDefinitions;
inherit (utils) templates baseBuilder;
keepLuaBuilder = utils.baseBuilder luaPath;
inherit dependencyOverlays;
# dependencyOverlays was wrapped with the ${system} variable earlier,
# so we export that here as well.
};
}