I’ve been playing around with subflakes as a sort of language agnostic glue for organizing a repo into smaller contexts that can be worked on without becoming dazzled by the bigger picture. I find the resulting network of inputs and outputs to be a useful structure.
I try to keep the internals of each flake as idiomatic for that language as possible so that I can drop an AI in there and say “fix this bug” and they don’t get confused or feel the need to wander too far.
But I’ve hit a snag that comes up whenever I want to link together two python-containing flakes in this way. Without nix I might do something like this in pyproject.toml of the consumer:
dependencies = [
"greeting-lib @ file:///home/matt/src/greeting-lib
]
And since there’s also a separate pyproject.toml in the indicated directory, uv is smart enough to install its transitive dependencies also. I don’t have to duplicate them here.
In general I’m a huge fan of uv2nix as a bridge between the nix world and whatever’s in my pyproject.toml but I’ve been struggling to find a nice way to handle transitive dependencies if, instead of being resolved through a PyPI package, or a git repo, or a filepath (shown above), they’re resolved through a flake input.
I put together a simple repo which demonstrates my ugly workaround to this problem: GitHub - MatrixManAtYrService/twoflakes. It involves altering the PYTHONPATH to include the flake input and also copying the transitive dependencies into the consumer’s pyproject.toml
Is there a smarter way to handle this? Perhaps I could change my outputs so that the have a bit more metadata which is then used to implicitly add the transitive deps to the environment?
I’ve tried making them non-flake inputs so I can just point at them like any other filepath, but I end up hard-coding nix store paths when I do this, which feels brittle. It’s also not clear how to handle those nix store paths as env vars, because uv2nix creates the workspace which then becomes an input to wherever I might set the variable… so the work has been done too early for me to intervene with my variable hackery.
I’m considering making a feature request of uv2nix for this, but I wanted to get some other opinions first.