-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathflake.nix
More file actions
145 lines (139 loc) · 4.09 KB
/
flake.nix
File metadata and controls
145 lines (139 loc) · 4.09 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
{
description = "nvim-mcp - MCP server for Neovim";
inputs = {
utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
utils,
...
} @ inputs:
utils.lib.eachDefaultSystem
(
system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
inputs.fenix.overlays.default
];
};
lib = pkgs.lib;
git_dirty =
if (self.sourceInfo ? rev)
then "false"
else "true";
git_commit_sha =
self.sourceInfo.rev or (
if (self.sourceInfo ? dirtyRev)
then lib.strings.removeSuffix "-dirty" self.sourceInfo.dirtyRev
else "unknown"
);
git_last_modified = toString self.sourceInfo.lastModified or "unknown";
in {
packages = rec {
default = nvim-mcp;
nvim-mcp = let
toolchain = (pkgs.fenix.stable).minimalToolchain;
rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
meta = builtins.fromTOML (builtins.readFile ./Cargo.toml);
inherit (meta.package) version name;
in
rustPlatform.buildRustPackage {
pname = name;
inherit version;
meta = {
description = "MCP server for Neovim";
mainProgram = name;
};
src = ./.;
env = {
GIT_COMMIT_SHA = git_commit_sha;
GIT_DIRTY = git_dirty;
SOURCE_DATE_EPOCH = git_last_modified;
};
cargoLock = {lockFile = ./Cargo.lock;};
checkFlags = [
"--skip=integration_tests"
];
};
run-test = pkgs.writeShellApplication {
name = "run-test";
text = builtins.readFile ./scripts/run-test.sh;
};
run-cov = pkgs.writeShellApplication {
name = "run-cov";
text = builtins.readFile ./scripts/run-cov.sh;
};
};
apps = {
default = {
type = "app";
meta = {
description = "MCP server for Neovim";
};
program = lib.getExe self.packages.${system}.nvim-mcp;
};
test = {
type = "app";
meta = {
description = "Run tests";
};
program = lib.getExe self.packages.${system}.run-test;
};
cov = {
type = "app";
meta = {
description = "Run tests with coverage";
};
program = lib.getExe self.packages.${system}.run-cov;
};
};
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
(fenix.stable.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
"llvm-tools"
])
];
packages = with pkgs;
[
# Development
rust-analyzer-nightly
grcov
pre-commit
# Integration tests
neovim-unwrapped
lua-language-server
go
gopls
zig
zls
typescript
typescript-language-server
]
++ (with self.packages.${system}; [
run-test
run-cov
]);
shellHook = ''
# Unset SOURCE_DATE_EPOCH to prevent reproducible build timestamps during development.
# This allows timestamps to reflect the current time, which is useful for development workflows.
unset SOURCE_DATE_EPOCH
'';
};
};
}
);
}