Extend package to add python egg


I am trying to extend the deluge package to include an extra plugin which is distributed as a python egg. I will eventually enable deluge using this NixOS services module. I’ve thought of a few potential ways to do this in theory. But I am not sure the best way to do it. I am also unsure of how to implement these approaches.

Option 1. Add a derivation which simply wgets the .egg file. From there, maybe there’s a way to add the .egg file’s location in the nix store to PYTHON_PATH for the deluge service? For example, there is this extraPackages option in the deluge service. Is it possible to have a package that simply modifies/updates PYTHON_PATH? If so, I could specify my custom WgetTheEgg package in the extraPackage attribute.

Option 2. Somehow extend the deluge package nix file to have an extra step in the build phase that fetches the .egg file and places it in ${deluge}/.config/plugins/my_egg.egg. Placing the egg in that location is the standard method of adding plugin eggs to deluge. One clear issue with this approach is that I’m not sure how to specify the location of the .config directory in the deluge package since that option is configured in the deluge services module. I’m also not sure how to extend the deluge package with this extra step in the build phase.

Option 3. Instead of downloading the egg, I could write a derivation for building the plugin from the source directly using python3Packages.buildPythonPackage. This might be better practice - not sure. Even so, it remains unclear to me how I would add this to the PYTHON_PATH for deluge (not as a build-time dependency, but as a runtime dependency).

Any pointers would be greatly appreciated. And as I’m fairly new to Nix/NixOS, I’d also welcome any more general pointers on terminology or best practices or getting help. Thanks!