build(nix): deduplicate runtime/test deps and add pre-commit check hook
- flake.nix: extract shared runtimeDeps and testDeps lists for packages.default (with pytestCheckHook) and devShells.default, and configure git core.hooksPath in shellHook - .githooks/pre-commit: run ruff check, pyright, pytest, and nix flake check before each commit
This commit is contained in:
1 parent
c549c83e2c
commit
98ffc65cb1
2 files changed
+28
-10
No files matched your search
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if command -v ruff >/dev/null 2>&1 && command -v pyright >/dev/null 2>&1 && command -v pytest >/dev/null 2>&1; then
|
||||||
|
ruff check .
|
||||||
|
pyright
|
||||||
|
pytest
|
||||||
|
else
|
||||||
|
nix develop --command bash -c "ruff check . && pyright && pytest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
nix flake check
|
||||||
@@ -9,29 +9,32 @@
|
|||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
pythonEnv = pkgs.python3.withPackages (ps: [
|
ps = pkgs.python3Packages;
|
||||||
|
|
||||||
|
runtimeDeps = [
|
||||||
ps.websockets
|
ps.websockets
|
||||||
ps.mcp
|
ps.mcp
|
||||||
ps.asyncssh
|
ps.asyncssh
|
||||||
ps.uvicorn
|
ps.uvicorn
|
||||||
|
];
|
||||||
|
|
||||||
|
testDeps = [
|
||||||
ps.httpx
|
ps.httpx
|
||||||
ps.pytest
|
ps.pytest
|
||||||
ps.pytest-asyncio
|
ps.pytest-asyncio
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
pythonEnv = pkgs.python3.withPackages (_: runtimeDeps ++ testDeps);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.${system}.default = pkgs.python3Packages.buildPythonApplication {
|
packages.${system}.default = ps.buildPythonApplication {
|
||||||
pname = "lg-smtv-mcp";
|
pname = "lg-smtv-mcp";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
pyproject = true;
|
pyproject = true;
|
||||||
build-system = [ pkgs.python3Packages.setuptools ];
|
build-system = [ ps.setuptools ];
|
||||||
dependencies = with pkgs.python3Packages; [
|
dependencies = runtimeDeps;
|
||||||
websockets
|
nativeCheckInputs = [ ps.pytestCheckHook ] ++ testDeps;
|
||||||
mcp
|
|
||||||
asyncssh
|
|
||||||
uvicorn
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
@@ -42,6 +45,9 @@
|
|||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export PYTHONPATH="$PWD/src:${PYTHONPATH:-}"
|
export PYTHONPATH="$PWD/src:${PYTHONPATH:-}"
|
||||||
|
if [ -d .git ] && [ -d .githooks ]; then
|
||||||
|
git config core.hooksPath .githooks
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user