forked from utensils/mcp-nixos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
164 lines (152 loc) · 4.57 KB
/
Copy pathflake.nix
File metadata and controls
164 lines (152 loc) · 4.57 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
{
description = "MCP-NixOS - Model Context Protocol server for NixOS, Home Manager, and nix-darwin";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs =
inputs@{
self,
nixpkgs,
flake-parts,
...
}:
let
mkMcpNixos =
{
pkgs,
python3Packages ? pkgs.python3Packages,
}:
let
pyproject = pkgs.lib.importTOML ./pyproject.toml;
in
python3Packages.buildPythonApplication {
pname = pyproject.project.name;
inherit (pyproject.project) version;
pyproject = true;
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./pyproject.toml
./README.md
./LICENSE
./RELEASE_NOTES.md
./mcp_nixos
./tests
];
};
build-system = [ python3Packages.hatchling ];
dependencies = with python3Packages; [
fastmcp
requests
beautifulsoup4
];
pythonRelaxDeps = true;
doCheck = true;
nativeCheckInputs = with python3Packages; [
pytest
pytest-asyncio
pytest-cov
pytest-rerunfailures
];
checkPhase = ''
pytest tests/ -m unit
'';
dontCheckRuntimeDeps = true;
pythonImportsCheck = [ "mcp_nixos" ];
meta = {
inherit (pyproject.project) description;
homepage = "https://github.com/utensils/mcp-nixos";
license = pkgs.lib.licenses.mit;
mainProgram = "mcp-nixos";
};
};
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
flake = {
overlays.default = final: _: {
mcp-nixos = mkMcpNixos { pkgs = final; };
};
lib.mkMcpNixos = mkMcpNixos;
};
perSystem =
{ system, ... }:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
# fastmcp in nixpkgs has overly strict mcp version bounds
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
(pyFinal: pyPrev: {
fastmcp = pyPrev.fastmcp.overridePythonAttrs (_: {
dontCheckRuntimeDeps = true;
doCheck = false;
});
})
];
})
];
};
in
{
packages = rec {
mcp-nixos = mkMcpNixos { inherit pkgs; };
default = mcp-nixos;
docker = pkgs.dockerTools.buildLayeredImage {
name = "ghcr.io/utensils/mcp-nixos";
tag = mcp-nixos.version;
# Format: YYYYMMDDHHMMSS -> YYYY-MM-DDTHH:MM:SSZ
created =
let
d = self.lastModifiedDate;
in
"${builtins.substring 0 4 d}-${builtins.substring 4 2 d}-${builtins.substring 6 2 d}T${builtins.substring 8 2 d}:${builtins.substring 10 2 d}:${builtins.substring 12 2 d}Z";
contents = [
mcp-nixos
pkgs.cacert
];
config = {
Entrypoint = [ (pkgs.lib.getExe mcp-nixos) ];
Env = [
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
];
};
};
};
apps = rec {
mcp-nixos = {
type = "app";
program = pkgs.lib.getExe self.packages.${system}.mcp-nixos;
meta.description = "MCP server for NixOS, Home Manager, and nix-darwin";
};
default = mcp-nixos;
};
formatter = pkgs.nixfmt-rfc-style;
devShells.default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.mcp-nixos ];
packages = with pkgs.python3Packages; [
pkgs.python3
hatchling
build
pytest
pytest-asyncio
pytest-cov
pytest-rerunfailures
pytest-xdist
ruff
mypy
types-requests
types-beautifulsoup4
twine
];
};
};
};
}