diff --git a/pkgs/by-name/uv/uv/package.nix b/pkgs/by-name/uv/uv/package.nix index c068002c920ce..9c57f911f3566 100644 --- a/pkgs/by-name/uv/uv/package.nix +++ b/pkgs/by-name/uv/uv/package.nix @@ -8,9 +8,7 @@ rust-jemalloc-sys, # nativeBuildInputs - cmake, installShellFiles, - pkg-config, buildPackages, versionCheckHook, @@ -36,13 +34,7 @@ rustPlatform.buildRustPackage (finalAttrs: { rust-jemalloc-sys ]; - nativeBuildInputs = [ - cmake - installShellFiles - pkg-config - ]; - - dontUseCmakeConfigure = true; + nativeBuildInputs = [ installShellFiles ]; cargoBuildFlags = [ "--package" @@ -64,9 +56,7 @@ rustPlatform.buildRustPackage (finalAttrs: { '' ); - nativeInstallCheckInputs = [ - versionCheckHook - ]; + nativeInstallCheckInputs = [ versionCheckHook ]; versionCheckProgramArg = "--version"; doInstallCheck = true; diff --git a/pkgs/development/python-modules/uv/default.nix b/pkgs/development/python-modules/uv/default.nix index 57f9bd8238df7..2ab81cf60602c 100644 --- a/pkgs/development/python-modules/uv/default.nix +++ b/pkgs/development/python-modules/uv/default.nix @@ -1,37 +1,45 @@ { buildPythonPackage, - installShellFiles, - pkg-config, - rustPlatform, - pkgs, + hatchling, + lib, + uv, }: buildPythonPackage { - inherit (pkgs.uv) + inherit (uv) pname version src - cargoDeps - dontUseCmakeConfigure meta - cargoBuildFlags - postInstall - versionCheckProgramArg ; + pyproject = true; - postPatch = '' - substituteInPlace python/uv/_find_uv.py \ - --replace-fail '"""Return the uv binary path."""' "return '$out/bin/uv'" - ''; + build-system = [ hatchling ]; - nativeBuildInputs = [ - pkgs.cmake - installShellFiles - pkg-config - rustPlatform.cargoSetupHook - rustPlatform.maturinBuildHook - ]; + postPatch = + # Do not rely on path lookup at runtime to find the uv binary. + # Use the propagated binary instead. + '' + substituteInPlace python/uv/_find_uv.py \ + --replace-fail '"""Return the uv binary path."""' "return '${lib.getExe uv}'" + '' + # Sidestep the maturin build system in favour of reusing the binary already built by nixpkgs, + # to avoid rebuilding the uv binary for every active python package set. + + '' + substituteInPlace pyproject.toml \ + --replace-fail 'requires = ["maturin>=1.0,<2.0"]' 'requires = ["hatchling"]' \ + --replace-fail 'build-backend = "maturin"' 'build-backend = "hatchling.build"' + + cat >> pyproject.toml <