-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
191 lines (164 loc) · 5.66 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
/*
* SPDX-FileCopyrightText: 2024 Name <[email protected]>
*
* SPDX-License-Identifier: MPL-2.0
*/
{
description = "Nvame: My personal Neovim flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs =
{
self,
nixpkgs,
}:
{
packages =
nixpkgs.lib.genAttrs
[
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(
system:
let
lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages.${system};
# Defines the plugins
plugins = with pkgs.vimPlugins; [
# Telescope
plenary-nvim
telescope-nvim
telescope-file-browser-nvim
telescope-ui-select-nvim
# Helpers
which-key-nvim
todo-comments-nvim
# Greeter
alpha-nvim
# Themeing
catppuccin-nvim
rainbow-delimiters-nvim
# Treesitter
nvim-treesitter.withAllGrammars
nvim-treesitter-parsers.nix
nvim-treesitter-parsers.lua
nvim-treesitter-parsers.rust
nvim-treesitter-parsers.html
nvim-treesitter-parsers.javascript
nvim-treesitter-parsers.typescript
nvim-treesitter-parsers.json
nvim-treesitter-parsers.toml
nvim-treesitter-parsers.markdown
# Git
vim-fugitive
gitsigns-nvim
cmp-git
# LSP
nvim-lspconfig
cmp-nvim-lsp
# Snippets
luasnip
friendly-snippets
# Completions
nvim-cmp
cmp-buffer
cmp_luasnip
SchemaStore-nvim
];
# Defines the external packages required
packages = with pkgs; [
# Better grep
ripgrep
# Better file finding
fd
# LSP servers
nil # Nix
sumneko-lua-language-server # Lua
ltex-ls # LaTeX
# Formatting
nixfmt-rfc-style
];
in
{
default = self.packages.${system}.mainConfig;
# Joins the plugin derivations and the Neovim derivation into one
mainConfig = pkgs.symlinkJoin {
name = "nvim";
paths = [
pkgs.neovim-unwrapped
plugins
packages
];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
# HACK: Since we cannot just import our config files normally, we must add them to the plugins location and have them loaded as plugins.
# This will work as normal however :3
mkdir -p $out/plugin/config/
ln -s ${./config}/* $out/plugin/config/
# Wraps Neovim and makes it use the packages in the Nix store
wrapProgram $out/bin/nvim \
--add-flags '-u' \
--add-flags 'NORC' \
--add-flags '--cmd' \
--add-flags "'set packpath^=$out/ | set runtimepath^=$out/,$out/after/'" \
--set-default NVIM_APPNAME nvame
'';
# This ensures our package is licensed properly within Nix
meta = {
description = "My main Neovim configuration";
homepage = "https://git.garfunkles.space/nvame";
license = lib.licenses.mpl20;
maintainers = with lib.maintainers; [ "Name" ];
platforms = lib.platforms.all;
};
};
}
);
# Creates a NixOS module so that you can install Nvame configs with config.nvame
nixosModules.nvame =
{ system, lib, ... }:
{
options.nvameConfigs = lib.mkOption {
type = lib.types.attrs;
default = self.packages.${system}; # Default to the fixed set of packages
description = "The set of Nvame configs";
};
config.nvameConfigs = self.packages.${system};
};
nixosModules.default = self.nixosModules.nvame;
# Creates a home-manager module so that you can install Nvame configs with config.nvame
hmModules.nvame = self.nixosModules.nvame;
hmModules.default = self.hmModules.nvame;
# Creates a darwin module so that you can install Nvame configs with config.nvame
darwinModules.nvame = self.nixosModules.nvame;
darwinModules.default = self.darwinModules.nvame;
# Creates a devShell for use in Nix Direnv
devShells =
nixpkgs.lib.genAttrs
[
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
reuse
(self.packages.${system}.default)
];
shellHook = ''echo "You have now entered the dev-shell for Nvame. Please be sure to check for REUSE compliance."'';
};
}
);
};
}