nixpkgs/pkgs/by-name/uv/uv/package.nix
2025-05-30 21:21:41 +00:00

83 lines
1.8 KiB
Nix

{
lib,
stdenv,
rustPlatform,
fetchFromGitHub,
# buildInputs
rust-jemalloc-sys,
# nativeBuildInputs
installShellFiles,
buildPackages,
versionCheckHook,
python3Packages,
nix-update-script,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "uv";
version = "0.7.9";
src = fetchFromGitHub {
owner = "astral-sh";
repo = "uv";
tag = finalAttrs.version;
hash = "sha256-Q2HOR8kpHuCB4c61vS0yojyue5tYNCHpx/NuG0HGHl4=";
};
useFetchCargoVendor = true;
cargoHash = "sha256-oIgvufZsS65gL0SL8WQggjZ3UFPDfEpf0yM+kkkUiqg=";
buildInputs = [
rust-jemalloc-sys
];
nativeBuildInputs = [ installShellFiles ];
cargoBuildFlags = [
"--package"
"uv"
];
# Tests require python3
doCheck = false;
postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
let
emulator = stdenv.hostPlatform.emulator buildPackages;
in
''
installShellCompletion --cmd uv \
--bash <(${emulator} $out/bin/uv generate-shell-completion bash) \
--fish <(${emulator} $out/bin/uv generate-shell-completion fish) \
--zsh <(${emulator} $out/bin/uv generate-shell-completion zsh)
''
);
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
doInstallCheck = true;
passthru = {
tests.uv-python = python3Packages.uv;
updateScript = nix-update-script { };
};
meta = {
description = "Extremely fast Python package installer and resolver, written in Rust";
homepage = "https://github.com/astral-sh/uv";
changelog = "https://github.com/astral-sh/uv/blob/${finalAttrs.version}/CHANGELOG.md";
license = with lib.licenses; [
asl20
mit
];
maintainers = with lib.maintainers; [
bengsparks
GaetanLepage
prince213
];
mainProgram = "uv";
};
})