uv: add manual entry (#430257)

authored by Gaétan Lepage and committed by GitHub e2f132a0 e72df35e

Changed files
+37
doc
pkgs
by-name
uv
+1
doc/packages/index.md
··· 32 32 vcpkg.section.md 33 33 weechat.section.md 34 34 xorg.section.md 35 + uv.section.md 35 36 build-support.md 36 37 ```
+22
doc/packages/uv.section.md
··· 1 + # uv {#sec-uv} 2 + 3 + `uv` is an extremely fast Python package installer and resolver, written in Rust. 4 + It manages project dependencies and environments, with support for lockfiles, workspaces, and more. 5 + 6 + Due to `uv` being unaware that it is running on a NixOS system, by default, it will fetch dynamically-linked Python executables that will fail to run, as NixOS cannot run executables intended for generic Linux environments out of the box. 7 + To learn more on this, please visit 8 + https://nix.dev/guides/faq.html#how-to-run-non-nix-executables 9 + 10 + There are two ways to mitigate this: 11 + 12 + 1. Provide `uv` with a statically-linked Python executable (ideally from `nixpkgs`) via the [`UV_PYTHON` environment variable](https://docs.astral.sh/uv/reference/environment/#uv_python). Alternatively, the `--python` flag can also be used, but this is easy to forget. It is also helpful to forbid `uv` from downloading any Python binaries via the [`UV_PYTHON_DOWNLOADS` environment variable](https://docs.astral.sh/uv/reference/environment/#uv_python_downloads) by setting it to `never`. 13 + These variables can be set in `shell.nix` and `.env` files, which can be redistributed with the project to ensure other NixOS machines can execute the project. 14 + 15 + 2. Add `programs.nix-ld.enable = true` to your NixOS config. While functional, the previous option is to be preferred, as this is the "works on my machine" option, because redistributing Python projects that use `uv` to another NixOS machine that does not have `nix-ld` enabled will cause the same errors to occur. 16 + 17 + Additionally, there is the issue of modules from PyPI vendoring dynamically-linked libraries, such as `numpy`, which will also fail to work. 18 + This topic is not local to `uv`, but is deserving of documentation nonetheless. 19 + Setting `LD_LIBRARY_PATH` should be the solution of choice here. Either: 20 + 21 + 1. Use `lib.makeLibraryPath` to set `LD_LIBRARY_PATH` from a `shell.nix`, e.g. `LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.openssl pkgs.zlib pkgs.curl ]` 22 + 2. (If you have already enabled `nix-ld`) set `LD_LIBRARY_PATH` to `NIX_LD_LIBRARY_PATH`. Be aware this is not a silver bullet solution, as this simply provides a list of commonly used libraries, as is shown in `nixos/modules/programs/nix-ld.nix`.
+3
doc/redirects.json
··· 4594 4594 "sec-interop.cylonedx-fod": [ 4595 4595 "index.html#sec-interop.cylonedx-fod" 4596 4596 ], 4597 + "sec-uv": [ 4598 + "index.html#sec-uv" 4599 + ], 4597 4600 "module-system-module-argument-_prefix": [ 4598 4601 "index.html#module-system-module-argument-_prefix" 4599 4602 ],
+11
pkgs/by-name/uv/uv/package.nix
··· 69 69 70 70 meta = { 71 71 description = "Extremely fast Python package installer and resolver, written in Rust"; 72 + longDescription = '' 73 + `uv` manages project dependencies and environments, with support for lockfiles, workspaces, and more. 74 + 75 + Due to `uv`'s (over)eager fetching of dynamically-linked Python executables, 76 + as well as vendoring of dynamically-linked libraries within Python modules distributed via PyPI, 77 + NixOS users can run into issues when managing Python projects. 78 + See the Nixpkgs Reference Manual entry for `uv` for information on how to mitigate these issues: 79 + https://nixos.org/manual/nixpkgs/unstable/#sec-uv. 80 + 81 + For building Python projects with `uv` and Nix outside of nixpkgs, check out `uv2nix` at https://github.com/pyproject-nix/uv2nix. 82 + ''; 72 83 homepage = "https://github.com/astral-sh/uv"; 73 84 changelog = "https://github.com/astral-sh/uv/blob/${finalAttrs.version}/CHANGELOG.md"; 74 85 license = with lib.licenses; [