-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
144 lines (138 loc) · 4.43 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
{
description = "Overlay containing a wrapper around pkgs.neovim-unwrapped";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
neovim-nightly-overlay = {
url = "github:nix-community/neovim-nightly-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
};
};
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } (
{ lib, inputs, ... }:
{
imports = with inputs; [
flake-parts.flakeModules.easyOverlay
pre-commit-hooks-nix.flakeModule
treefmt-nix.flakeModule
];
systems = lib.systems.flakeExposed;
perSystem =
{
config,
pkgs,
inputs',
...
}:
let
nvim = pkgs.callPackage ./wrapper.nix { };
overrides = {
repo = "https://github.com/name-snrl/nvim";
viAlias = true;
withPython3 = true;
extraBinPath = [ pkgs.deadnix ];
extraTSParsers = with pkgs.vimPlugins.nvim-treesitter-parsers; [
fish
scala
starlark
];
};
test-nightly = nvim.override (
overrides
// {
extraName = "-test-nightly";
rebuildWithTSParsers = true;
neovim-unwrapped = inputs'.neovim-nightly-overlay.packages.neovim;
}
);
test-stable = nvim.override (overrides // { extraName = "-test-stable"; });
update = pkgs.writeShellApplication {
name = "update";
text = ''
nix flake update \
--commit-lock-file \
--inputs-from self \
--override-input nixpkgs nixpkgs \
--override-input neovim-nightly-overlay neovim-nightly-overlay &&
direnv reload
'';
};
in
{
packages = {
inherit test-nightly test-stable update;
};
overlayAttrs = {
inherit nvim;
};
treefmt = {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
deadnix.enable = true;
statix.enable = true; # fix, if possible
stylua.enable = true;
mdformat.enable = true;
mdformat.package = pkgs.mdformat.withPlugins (
p: with p; [
mdformat-gfm
mdformat-frontmatter
mdformat-footnote
]
);
};
settings.formatter.mdformat.options = [
"--wrap"
"80"
];
};
pre-commit.settings = {
hooks = {
treefmt = {
enable = true;
package = config.treefmt.build.wrapper;
};
statix.enable = true; # check. not everything can be fixed, but we need to know what
selene = {
enable = true;
name = "selene";
description = "An opinionated Lua code linter";
entry = "${pkgs.selene}/bin/selene --config ${./selene}/selene.toml";
types = [ "lua" ];
};
};
};
devShells.default =
with pkgs;
mkShellNoCC {
packages = [
update
(writeShellApplication {
name = "nightly";
text = "nix shell .#test-nightly";
})
(writeShellApplication {
name = "stable";
text = "nix shell .#test-stable";
})
];
shellHook = config.pre-commit.installationScript;
};
};
}
);
}