diff --git a/flake.nix b/flake.nix index 5372b4bfd..815cb5738 100644 --- a/flake.nix +++ b/flake.nix @@ -110,7 +110,7 @@ nixpkgs-fmt.enable = true; ruff-format = { enable = true; - excludes = [ "rust/exo_rs/exo_rs.pyi" ]; + excludes = [ "rust/exo_rs/python/**/*.pyi" ]; }; rustfmt = { enable = true; diff --git a/python/parts.nix b/python/parts.nix index 26318c4a2..95bfcb081 100644 --- a/python/parts.nix +++ b/python/parts.nix @@ -46,7 +46,6 @@ let exoOverlay = final: prev: { # Replace workspace exo_rs with Nix-built wheel. # Preserve passthru so mkVirtualEnv can resolve dependency groups. - # Copy .pyi stub + py.typed marker so basedpyright can find the types. exo-rs = pkgs.stdenv.mkDerivation { pname = "exo-rs"; version = "0.1.0"; @@ -55,12 +54,6 @@ let nativeBuildInputs = [ final.pyprojectWheelHook ]; dontStrip = true; passthru = prev.exo-rs.passthru or { }; - - postInstall = '' - local siteDir=$out/${final.python.sitePackages}/exo_rs - cp ${inputs.self}/rust/exo_rs/exo_rs.pyi $siteDir/ - touch $siteDir/py.typed - ''; }; }; buildSystemsOverlay = final: prev: diff --git a/rust/parts.nix b/rust/parts.nix index 3fa8e2dab..dd7982f12 100644 --- a/rust/parts.nix +++ b/rust/parts.nix @@ -32,8 +32,17 @@ isRootCargoFile = (baseName == "Cargo.toml" || baseName == "Cargo.lock") && (builtins.dirOf path == toString inputs.self); + isExoRsPythonSource = + (lib.hasInfix "/rust/exo_rs/python/" path || lib.hasSuffix "/rust/exo_rs/python" path) + && ( + type == "directory" + || lib.hasSuffix ".py" path + || lib.hasSuffix ".pyi" path + || baseName == "py.typed" + ); in isRootCargoFile + || isExoRsPythonSource || (inRustDir && (craneLib.filterCargoSources path type || lib.hasSuffix ".toml" path || lib.hasSuffix ".md" path)); };