Skip to content

Conversation

adisbladis
Copy link
Member

This adds a hacks.toNixpkgs that generates a Nixpkgs overlay from pyproject.nix build (uv2nix) packages. It is conceptually similar to hacks.nixpkgsPrebuilt, just in reverse.

@adisbladis adisbladis changed the title build: Add hacks function for 2-way Nixpkgs Python infrastructure build: Add hacks function for 2-way Nixpkgs Python infrastructure interop Aug 28, 2025
@ezemtsov
Copy link

ezemtsov commented Sep 5, 2025

@adisbladis thanks for the short talk at nixcon today!

Just not to have the results of our conversation lost, leaving a comment here.

Do you think it would be possible to setup hacks.toNixpkgs override to select all packages automatically from the uv lock file? It would be potentially easy to extract pname properties from pythonSet, but at this point it is mixed with many irrelevant attributes, such as pyprojectDistHook or pyprojectWheelHook.

Maybe we could move out hooks and other irrelevant attributes from the resulting pythonSet?

@adisbladis
Copy link
Member Author

Do you think it would be possible to setup hacks.toNixpkgs override to select all packages automatically from the uv lock file? It would be potentially easy to extract pname properties from pythonSet, but at this point it is mixed with many irrelevant attributes, such as pyprojectDistHook or pyprojectWheelHook.

Yep! I've now implemented the packages arg in three different modes:

  • null (default)
    Include all generated packages
  • list
    Include explicitly listed packages
  • predicate
    A predicate function that filters the list of attributes to generate

This adds a `hacks.toNixpkgs` that generates a Nixpkgs overlay from pyproject.nix build (uv2nix) packages.
It is conceptually similar to `hacks.nixpkgsPrebuilt`, just in reverse.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants