{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; }; outputs = { self, nixpkgs }: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; # Python with custom packages python = pkgs.python313.override { self = python; packageOverrides = pyfinal: pyprev: { # Leaf packages (no custom dependencies) mistletoe = pyfinal.callPackage ./packages/mistletoe.nix { }; sse-starlette = pyfinal.callPackage ./packages/sse-starlette.nix { }; fastcore = pyfinal.callPackage ./packages/fastcore.nix { }; # Second level (depend on leaf packages) apswutils = pyfinal.callPackage ./packages/apswutils.nix { }; fastlite = pyfinal.callPackage ./packages/fastlite.nix { }; fastmigrate = pyfinal.callPackage ./packages/fastmigrate.nix { }; # Top level (depend on second level) python-fasthtml = pyfinal.callPackage ./packages/python-fasthtml.nix { }; monsterui = pyfinal.callPackage ./packages/monsterui.nix { }; }; }; # Shared Python environment for both dev and Docker pythonEnv = python.withPackages (ps: with ps; [ # From nixpkgs uvicorn starlette httpx pydantic pydantic-settings anyio beautifulsoup4 python-dateutil oauthlib itsdangerous python-multipart lxml apsw packaging python-ulid xxhash # Custom packages fastcore apswutils fastlite fastmigrate sse-starlette python-fasthtml monsterui mistletoe # Dev-only (not needed in Docker, but fine to include) pytest pytest-xdist ruff filelock ]); in { packages.${system} = { dockerImage = let buildDate = let d = self.lastModifiedDate or "00000000000000"; in "${builtins.substring 0 4 d}-${builtins.substring 4 2 d}-${builtins.substring 6 2 d}"; buildCommit = self.shortRev or self.dirtyShortRev or "unknown"; in import ./docker.nix { inherit pkgs pythonEnv python buildDate buildCommit; }; }; devShells.${system}.default = pkgs.mkShell { buildInputs = [ pythonEnv # Tools pkgs.jq pkgs.sqlite pkgs.skopeo # For pushing Docker images pkgs.lefthook # Git hooks manager ]; shellHook = '' export PYTHONPATH="$PWD/src:$PYTHONPATH" export PATH="$PWD/bin:$PATH" echo "AnimalTrack development environment ready!" echo "Run 'animaltrack serve' to start the app" ''; }; }; }