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:
kiskaadee committed 2026-11-15 12:11:53 -05:00
1 parent c549c83e2c
commit 98ffc65cb1
2 files changed
+28 -10

No files matched your search

+12
View File
@@ -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
+16 -10
View File
@@ -9,29 +9,32 @@
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
pythonEnv = pkgs.python3.withPackages (ps: [
ps = pkgs.python3Packages;
runtimeDeps = [
ps.websockets
ps.mcp
ps.asyncssh
ps.uvicorn
];
testDeps = [
ps.httpx
ps.pytest
ps.pytest-asyncio
]);
];
pythonEnv = pkgs.python3.withPackages (_: runtimeDeps ++ testDeps);
in
{
packages.${system}.default = pkgs.python3Packages.buildPythonApplication {
packages.${system}.default = ps.buildPythonApplication {
pname = "lg-smtv-mcp";
version = "0.1.0";
src = ./.;
pyproject = true;
build-system = [ pkgs.python3Packages.setuptools ];
dependencies = with pkgs.python3Packages; [
websockets
mcp
asyncssh
uvicorn
];
build-system = [ ps.setuptools ];
dependencies = runtimeDeps;
nativeCheckInputs = [ ps.pytestCheckHook ] ++ testDeps;
};
devShells.${system}.default = pkgs.mkShell {
@@ -42,6 +45,9 @@
];
shellHook = ''
export PYTHONPATH="$PWD/src:${PYTHONPATH:-}"
if [ -d .git ] && [ -d .githooks ]; then
git config core.hooksPath .githooks
fi
'';
};
};