Let’s say I am on Ubuntu and I have Poetry installed. Then, let’s say I need to debug a dependency of my Poetry-based Python project. I can mark the dependency as develop=true and it will be checked out into .venv/src/ where I can edit its source directly to add a pdb.set_trace, fix a bug, etc.
However, when using poetry2nix, all dependencies are installed in Nix store, which is read-only, so I cannot edit the dependency’s source. What is the recommended way to “develop” a dependency in a poetry2nix project?
➜ which python
/nix/store/5wx6i7bpnm3a7hcz8xn2rzz6x5gpa1ki-python3-3.8.6-env/bin/python
➜ vim /nix/store/5wx6i7bpnm3a7hcz8xn2rzz6x5gpa1ki-python3-3.8.6-env/lib/python3.8/site-packages/requests/auth.py
# --> read-only file, can't save my change
Because I am on MacOS, I have a workaround that I am currently using: open the file up with Sublime Text 3, which asks for sudo password, then actually allows me to edit it.
Yeah, editing files in the nix store is definitely not ideal, and not intentional, as the Nix store being read-only is both a feature and a requirement.
If you need to edit or debug a dependency, that should be done in its own project so as to allow for encapsulating your testing, and ensuring that you don’t touch a dependent app while keeping it modular.
95% of the cases I don’t need more than insert a pdb.set_trace into a dependency, to understand how it works so I can use it correcly, or in some rare case, monkey-patch it in my code.
Creating a new bespoke project for every dependency that I need to insert this one line into every time I need to do it seems very tedious and time consuming. Surely there is a better way?
Note for the above: obviously, if pyramid_mixpanel depends on mixpanel lib, and you comment out pyramid_mixpanel from pyproject.toml, then you have to (temporarily) add mixpanel = "*".
Clone dependency into ./src directory: $ cd src/ && git clone git@github.com:teamniteo/pyramid_mixpanel.git
In pyproject.toml, replace pyramid-mixpanel = "*" with { path = "./src/pyramid_mixpanel/", develop = true }
Now nix-shell should pick up the locally checked out repo instead of taking the source from /nix/store. No need to edit default.nix or manually add indirect dependencies to pyproject.toml any more!