Skip to content

Commit 64c31ed

Browse files
authored
Add Nix packaging and flake.nix for MCPM (#161)
1 parent d3dabd2 commit 64c31ed

File tree

5 files changed

+237
-0
lines changed

5 files changed

+237
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ wheels/
2121
.installed.cfg
2222
*.egg
2323

24+
# Nix Build
25+
result
26+
2427
# Virtual environments
2528
.venv
2629
venv/

README.nix.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# MCPM Nix Packaging
2+
3+
This repository contains Nix packaging for MCPM (Model Context Protocol Manager).
4+
5+
## Using with Nix Flakes
6+
7+
If you have flakes enabled, you can use this package directly:
8+
9+
```bash
10+
# Run MCPM directly
11+
nix run .
12+
13+
# Install MCPM to your profile
14+
nix profile install github:pathintegral-institute/mcpm.sh
15+
16+
# Enter a development shell
17+
nix develop .
18+
```
19+
20+
## Building from Source
21+
22+
To build the package from source:
23+
24+
1. Clone the repository:
25+
```bash
26+
git clone https://github.com/pathintegral-institute/mcpm.sh
27+
cd mcpm.sh
28+
```
29+
30+
2. Build the package:
31+
```bash
32+
nix build
33+
```
34+
35+
3. Run the built package:
36+
```bash
37+
./result/bin/mcpm --help
38+
```
39+
40+
## Notes
41+
42+
- The nix package requires Python 3.12 or higher.
43+

default.nix

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
lib,
3+
python3,
4+
}:
5+
6+
let
7+
# Use Python 3.12
8+
python = python3; # pkgs.python312;
9+
10+
# Override Python to include our custom packages
11+
pythonWithPackages = python.override {
12+
packageOverrides = self: super: {
13+
# Add our custom packages
14+
};
15+
};
16+
in
17+
pythonWithPackages.pkgs.buildPythonApplication rec {
18+
pname = "mcpm";
19+
version = "1.13.1"; # From src/mcpm/version.py
20+
21+
src = ./.; # Use the local directory as the source
22+
23+
format = "pyproject";
24+
25+
nativeBuildInputs = with pythonWithPackages.pkgs; [
26+
hatchling
27+
setuptools
28+
wheel
29+
pip
30+
];
31+
32+
propagatedBuildInputs = with pythonWithPackages.pkgs; [
33+
# Core dependencies from pyproject.toml
34+
click
35+
rich
36+
requests
37+
pydantic
38+
duckdb
39+
psutil
40+
prompt-toolkit
41+
deprecated
42+
43+
# dependencies only available for Python>=3.12 on nixpkgs
44+
mcp
45+
ruamel-yaml
46+
watchfiles
47+
48+
# Additional dependencies that might be needed
49+
typer
50+
httpx
51+
anyio
52+
fastapi
53+
uvicorn
54+
websockets
55+
jinja2
56+
pyyaml
57+
toml
58+
python-dotenv
59+
packaging
60+
colorama
61+
];
62+
63+
# Disable tests for now
64+
#doCheck = false;
65+
66+
meta = with lib; {
67+
description = "MCPM - Model Context Protocol Manager";
68+
homepage = "https://mcpm.sh";
69+
license = licenses.mit;
70+
maintainers = with maintainers; [ luochen1990 ];
71+
mainProgram = "mcpm";
72+
};
73+
}

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
description = "MCPM - Model Context Protocol Manager";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
...
15+
}:
16+
flake-utils.lib.eachDefaultSystem (
17+
system:
18+
let
19+
pkgs = import nixpkgs {
20+
inherit system;
21+
config = {
22+
allowUnfree = true;
23+
permittedInsecurePackages = [ ];
24+
};
25+
};
26+
in
27+
{
28+
packages = {
29+
default = pkgs.callPackage ./default.nix { };
30+
};
31+
32+
apps.default = flake-utils.lib.mkApp {
33+
drv = self.packages.${system}.default;
34+
};
35+
36+
devShells.default = pkgs.mkShell {
37+
inputsFrom = [ self.packages.${system}.default ];
38+
39+
buildInputs = with pkgs.python3.pkgs; [
40+
self.packages.${system}.default
41+
42+
# From pyproject.toml's dev dependencies
43+
ipython
44+
pytest
45+
pytest-asyncio
46+
ruff
47+
jsonschema
48+
openai
49+
];
50+
51+
shellHook = ''
52+
echo "MCPM development environment"
53+
'';
54+
};
55+
}
56+
);
57+
}

0 commit comments

Comments
 (0)