Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions pkgs/by-name/uv/uv/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
rust-jemalloc-sys,

# nativeBuildInputs
cmake,
installShellFiles,
pkg-config,

buildPackages,
versionCheckHook,
Expand All @@ -36,13 +34,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
rust-jemalloc-sys
];

nativeBuildInputs = [
cmake
installShellFiles
pkg-config
];

dontUseCmakeConfigure = true;
nativeBuildInputs = [ installShellFiles ];

cargoBuildFlags = [
"--package"
Expand All @@ -64,9 +56,7 @@ rustPlatform.buildRustPackage (finalAttrs: {
''
);

nativeInstallCheckInputs = [
versionCheckHook
];
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
doInstallCheck = true;

Expand Down
52 changes: 30 additions & 22 deletions pkgs/development/python-modules/uv/default.nix
Original file line number Diff line number Diff line change
@@ -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 <<EOF
[tool.hatch.build]
packages = ['python/uv']

EOF
'';

postInstall = ''
mkdir -p $out/bin && ln -s ${lib.getExe uv} $out/bin/uv
'';

pyproject = true;
pythonImportsCheck = [ "uv" ];
}
2 changes: 1 addition & 1 deletion pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18613,7 +18613,7 @@ self: super: with self; {

uuid6 = callPackage ../development/python-modules/uuid6 { };

uv = callPackage ../development/python-modules/uv { };
uv = callPackage ../development/python-modules/uv { inherit (pkgs) uv; };

uv-build = callPackage ../development/python-modules/uv-build { };

Expand Down