-
-
Notifications
You must be signed in to change notification settings - Fork 307
/
Copy pathflake.nix
160 lines (150 loc) · 4.79 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
{
description = "A neovim configuration system for NixOS";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
beautysh = {
url = "github:lovesegfault/beautysh";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
...
} @ inputs:
with nixpkgs.lib;
with builtins; let
# TODO: Support nesting
nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules));
modules = pkgs:
nixvimModules
++ [
rec {
_file = ./flake.nix;
key = _file;
config = {
_module.args = {
pkgs = mkForce pkgs;
inherit (pkgs) lib;
helpers = import ./plugins/helpers.nix {inherit (pkgs) lib;};
inherit inputs;
};
};
}
# ./plugins/default.nix
];
wrapperArgs = {
inherit modules;
inherit self;
};
flakeOutput =
flake-utils.lib.eachDefaultSystem
(system: let
pkgs = import nixpkgs {inherit system;};
# Some nixvim supported plugins require the use of unfree packages.
# This unfree-friendly pkgs is used for documentation and testing only.
pkgs-unfree = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in {
checks =
(import ./tests {
inherit pkgs;
inherit (pkgs) lib;
# Some nixvim supported plugins require the use of unfree packages.
# As we test as many things as possible, we need to allow unfree sources by generating
# a separate `makeNixvim` module (with pkgs-unfree).
makeNixvim = let
makeNixvimWithModuleUnfree = import ./wrappers/standalone.nix pkgs-unfree wrapperArgs;
in
configuration:
makeNixvimWithModuleUnfree {
module = {
config = configuration;
};
};
})
// {
lib-tests = import ./tests/lib-tests.nix {
inherit (pkgs) pkgs lib;
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra = {
enable = true;
excludes = ["plugins/_sources"];
};
statix.enable = true;
};
settings.statix.ignore = ["plugins/lsp/language-servers/rust-analyzer-config.nix"];
};
};
devShells = {
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
};
packages =
{
docs = pkgs-unfree.callPackage (import ./docs) {
modules = modules pkgs;
};
}
// (import ./helpers pkgs)
// (import ./man-docs {
pkgs = pkgs-unfree;
modules = modules pkgs;
});
legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs wrapperArgs;
makeNixvim = configuration:
makeNixvimWithModule {
module = {
config = configuration;
};
};
};
formatter = pkgs.alejandra;
lib = import ./lib {
inherit pkgs;
inherit (pkgs) lib;
inherit (self.legacyPackages."${system}") makeNixvim;
};
});
in
flakeOutput
// {
nixosModules.nixvim = import ./wrappers/nixos.nix wrapperArgs;
homeManagerModules.nixvim = import ./wrappers/hm.nix wrapperArgs;
nixDarwinModules.nixvim = import ./wrappers/darwin.nix wrapperArgs;
rawModules.nixvim = nixvimModules;
overlays.default = final: prev: {
nixvim = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix prev wrapperArgs;
makeNixvim = configuration:
makeNixvimWithModule {
module = {
config = configuration;
};
};
};
};
templates = let
simple = {
path = ./templates/simple;
description = "A simple nix flake template for getting started with nixvim";
};
in {
default = simple;
};
};
}