Files
lg-smtv-mcp/flake.nix
kiskaadee 28d3a8cbab feat(config): enforce Pydantic v2 TvConfig validation and raise ConfigError
- Add standalone ConfigError(Exception) in errors.py decoupled from runtime TvError
- Convert TvConfig from dataclass to frozen Pydantic v2 BaseModel with field_validator hooks using PydanticCustomError
- Validate TV_IP and WOL_BROADCAST as IPv4 addresses, PORT in 1..65535, and MAX_VOLUME in 0..100 on both load_config() and direct TvConfig instantiation
- Redirect Pydantic ValidationError to ConfigError in TvConfig.__init__ and raise ConfigError from require_bearer_token/require_mac
- Declare pydantic explicitly in flake.nix runtimeDeps and pyproject.toml dependencies
- Expand tests/test_config.py to cover ConfigError and direct TvConfig validation
2026-11-15 13:20:41 -05:00

65 lines
1.4 KiB
Nix

{
description = "LG Smart TV (webOS) MCP server and testing environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
ps = pkgs.python3Packages;
runtimeDeps = [
ps.websockets
ps.mcp
ps.pydantic
ps.asyncssh
ps.uvicorn
];
testDeps = [
ps.httpx
ps.pytest
ps.pytest-asyncio
];
pythonEnv = pkgs.python3.withPackages (_: runtimeDeps ++ testDeps);
in
{
packages.${system}.default = ps.buildPythonApplication {
pname = "lg-smtv-mcp";
version = "0.1.0";
src = ./.;
pyproject = true;
build-system = [ ps.setuptools ];
dependencies = runtimeDeps;
nativeCheckInputs = [
ps.pytestCheckHook
pkgs.ruff
pkgs.pyright
] ++ testDeps;
preCheck = ''
ruff check .
ruff format --check .
pyright
'';
};
devShells.${system}.default = pkgs.mkShell {
packages = [
pythonEnv
pkgs.pyright
pkgs.ruff
];
shellHook = ''
export PYTHONPATH="$PWD/src:${PYTHONPATH:-}"
if [ -d .git ] && [ -d .githooks ]; then
git config core.hooksPath .githooks
fi
'';
};
};
}