Skip to content

Commit 15aaa0d

Browse files
committed
Add Nix packaging and flake.nix for MCPM
1 parent 549d56c commit 15aaa0d

File tree

5 files changed

+263
-0
lines changed

5 files changed

+263
-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: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 github:luochen1990/mcpm-flake
12+
13+
# Install MCPM to your profile
14+
nix profile install github:luochen1990/mcpm-flake
15+
16+
# Enter a development shell
17+
nix develop github:luochen1990/mcpm-flake
18+
```
19+
20+
## Using without Flakes
21+
22+
For users who don't use flakes, a `shell.nix` file is provided:
23+
24+
```bash
25+
# Enter a development shell
26+
nix-shell
27+
28+
# Or build the package
29+
nix-build
30+
```
31+
32+
## Package Structure
33+
34+
The Nix packaging is organized as follows:
35+
36+
- `/nix/default.nix`: Main package definition for MCPM
37+
- `/nix/packages/`: Directory containing package definitions for dependencies
38+
- `/nix/packages/mcp/`: Package definition for MCP dependency
39+
- `/nix/packages/ruamel-yaml/`: Package definition for ruamel-yaml dependency
40+
- `/nix/packages/watchfiles/`: Package definition for watchfiles dependency
41+
- `/nix/packages/mcpm/`: Alternative package definition for MCPM
42+
- `/flake.nix`: Nix flake definition
43+
- `/shell.nix`: Compatibility wrapper for non-flake Nix users
44+
45+
## Building from Source
46+
47+
To build the package from source:
48+
49+
1. Clone the repository:
50+
```bash
51+
git clone https://github.com/luochen1990/mcpm-flake.git
52+
cd mcpm-flake
53+
```
54+
55+
2. Build the package:
56+
```bash
57+
nix build
58+
```
59+
60+
3. Run the built package:
61+
```bash
62+
./result/bin/mcpm --help
63+
```
64+
65+
## Notes
66+
67+
- The SHA256 hashes in the dependency package definitions are placeholders and need to be replaced with actual hashes when building the package.
68+
- The package requires Python 3.11 or higher.
69+
- All dependencies are managed through Nix and don't rely on pip, npm, or other external package managers.

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)