forked from NotAShelf/nvf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
193 lines (171 loc) · 5.81 KB
/
Copy pathflake.nix
File metadata and controls
193 lines (171 loc) · 5.81 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
{
description = "A neovim flake with a modular configuration";
outputs = {
self,
nixpkgs,
...
} @ inputs: let
systems = nixpkgs.lib.systems.flakeExposed;
# Provide simple per-system abstraction
# giving you the system and
# the package set for that system directly.
eachSystem = f:
nixpkgs.lib.genAttrs systems
(system: f system nixpkgs.legacyPackages.${system});
# Call the extended library with `inputs`.
# inputs is used to get the original standard library, and to pass inputs
# to the plugin autodiscovery function
lib = import ./lib/stdlib-extended.nix {inherit inputs self;};
in {
lib = {
inherit (lib) nvim;
inherit (lib.nvim) neovimConfiguration;
};
inherit (lib.importJSON ./npins/sources.json) pins;
homeManagerModules = {
nvf = import ./flake/modules/home-manager.nix {inherit lib inputs;};
default = self.homeManagerModules.nvf;
neovim-flake =
lib.warn ''
'homeManagerModules.neovim-flake' has been deprecated, and will be removed
in a future release. Please use 'homeManagerModules.nvf' instead.
''
self.homeManagerModules.nvf;
};
nixosModules = {
nvf = import ./flake/modules/nixos.nix {inherit lib inputs;};
default = self.nixosModules.nvf;
neovim-flake =
lib.warn ''
'nixosModules.neovim-flake' has been deprecated, and will be removed
in a future release. Please use 'nixosModules.nvf' instead.
''
self.nixosModules.nvf;
};
darwinModules = {
nvf = import ./flake/modules/nixos.nix {inherit lib inputs;};
default = self.darwinModules.nvf;
};
# Provides the default formatter for 'nix fmt', which will format the
# entire Nix source with Alejandra. The wrapper script is necessary due to
# changes to the behaviour of Nix, which now encourages wrappers for
# tree-wide formatting.
formatter = eachSystem (
_: pkgs:
pkgs.writeShellApplication {
name = "nix3-fmt-wrapper";
runtimeInputs = [
pkgs.alejandra
pkgs.fd
pkgs.deno
];
text = ''
# Find Nix files in the tree and format them with Alejandra
echo "Formatting Nix files"
fd "$@" -t f -e nix -x alejandra -q '{}'
# Same for Markdown files, but with deno
echo "Formatting Markdown files"
fd "$@" -t f -e md -x deno fmt -q '{}'
'';
}
);
# Provides checks to be built an ran on 'nix flake check'. They can also
# be built individually with 'nix build' as described below.
checks = eachSystem (system: pkgs:
{
# Check if codebase is properly formatted.
# This can be initiated with `nix build .#checks.<system>.nix-fmt`
# or with `nix flake check`
nix-fmt =
pkgs.runCommand "nix-fmt-check"
{
src = self;
nativeBuildInputs = [pkgs.alejandra pkgs.fd];
} ''
cd "$src"
fd -t f -e nix -x alejandra --check '{}'
touch $out
'';
# Check if Markdown sources are properly formatted
# This can be initiated with `nix build .#checks.<system>.md-fmt`
# or with `nix flake check`
md-fmt =
pkgs.runCommand "md-fmt-check" {
src = self;
nativeBuildInputs = [pkgs.deno pkgs.fd];
} ''
cd "$src"
fd -t f -e md -x deno fmt --check '{}'
touch $out
'';
}
// import ./flake/checks.nix {inherit pkgs self system;});
templates = import ./flake/templates;
apps = eachSystem (system: _: let
inherit (lib.meta) getExe;
in {
nix = {
type = "app";
program = getExe self.packages.${system}.nix;
meta = {};
};
maximal = {
type = "app";
program = getExe self.packages.${system}.maximal;
meta = {};
};
default = self.apps.${system}.nix;
});
packages = let
inherit (lib.attrsets) recursiveUpdate;
in
recursiveUpdate
(eachSystem (system: _: import ./flake/packages.nix {inherit inputs lib self system;}))
(eachSystem (_: pkgs: {
# This package exists to make development easier by providing the place and
# boilerplate to build a test nvf configuration. Feel free to use this for
# testing, but make sure to discard the changes before creating a pull
# request.
dev = let
configuration = {
# This is essentially the configuration that will be passed to the
# builder function. For example:
# vim.languages.nix.enable = true;
};
customNeovim = lib.nvim.neovimConfiguration {
inherit pkgs;
modules = [configuration];
};
in
customNeovim.neovim;
}));
devShells = eachSystem (_: pkgs: {
# The default dev shell provides packages required to interact with
# the codebase as described by the contributing guidelines. It includes the
# formatters required, and a few additional goodies for linting work.
default = pkgs.mkShellNoCC {
packages = with pkgs; [
# Nix tooling
nil # LSP
statix # static checker
deadnix # dead code finder
# So that we can interact with plugin sources
npins
# Formatters
alejandra
deno
];
};
});
};
inputs = {
## Basic Inputs
nixpkgs.url = "https://channels.nixos.org/nixos-26.05/nixexprs.tar.xz";
flake-compat = {
url = "git+https://git.lix.systems/lix-project/flake-compat.git";
flake = false;
};
# Alternate neovim-wrapper
mnw.url = "github:Gerg-L/mnw";
};
}