{ sources ? import ./npins, overlay ? import ./nix/overlay.nix, pkgs ? import sources.nixpkgs { overlays = [ overlay ]; }, }: let self = rec { inherit (pkgs) python3; package = pkgs.evolive; pre-commit-check = pkgs.pre-commit-hooks { src = ./.; hooks = let pythonExcludes = [ "/migrations/" # auto-generated code ]; in { # Nix setup nixfmt = { enable = true; entry = pkgs.lib.mkForce "${pkgs.lib.getExe pkgs.nixfmt-rfc-style}"; }; statix = { enable = true; settings.ignore = [ "npins" ]; }; # Python setup ruff = { enable = true; excludes = pythonExcludes; }; ruff-format = { enable = true; name = "Format python code with ruff"; types = [ "text" "python" ]; entry = "${pkgs.lib.getExe pkgs.ruff} format"; excludes = pythonExcludes; }; pyright = let pyEnv = pkgs.python3.buildEnv.override { extraLibs = pkgs.evolive.propagatedBuildInputs; # Necessary for FastAPI CLI. ignoreCollisions = true; }; wrappedPyright = pkgs.runCommand "pyright" { nativeBuildInputs = [ pkgs.makeWrapper ]; } '' makeWrapper ${pkgs.pyright}/bin/pyright $out \ --set PYTHONPATH ${pyEnv}/${pyEnv.sitePackages} \ --prefix PATH : ${pyEnv}/bin \ --set PYTHONHOME ${pyEnv} ''; in { enable = true; entry = pkgs.lib.mkForce (builtins.toString wrappedPyright); excludes = pythonExcludes; }; # Global setup prettier = { enable = true; excludes = [ "\\.min.css$" "\\.html$" ]; }; commitizen.enable = true; }; }; shell = pkgs.mkShell { DATA_CACHE_DIRECTORY = toString ./. + "/.data_cache"; REDIS_SOCKET_URL = "unix:///run/redis/redis.sock"; # `./src/website/tracker/settings.py` by default looks for LOCAL_NIXPKGS_CHECKOUT # in the root of the repo. Make it the default here for local development. LOCAL_NIXPKGS_CHECKOUT = toString ./. + "/nixpkgs"; packages = [ package # (pkgs.python3.buildEnv.override { # extraLibs = with pkgs.python3.pkgs; [ fastapi uvicorn ]; # ignoreCollisions = true; # }) pkgs.nix-eval-jobs pkgs.commitizen pkgs.npins pkgs.nixfmt-rfc-style pkgs.hivemind ]; shellHook = '' ${pre-commit-check.shellHook} mkdir -p .credentials export DATABASE_URL=postgres:///evolive export CREDENTIALS_DIRECTORY=${builtins.toString ./.credentials} ''; }; # tests = import ./nix/tests/vm-basic.nix { # inherit pkgs; # wstModule = module; # }; }; in self # // self.tests