I am writing a python application which also has a runtime dependency on
redis. I am using poetry2nix to build the application and package this up however I am not able to figure out how or whats the best way to add non-python dependencies to a poetry project (using
Any guidance on this would be really appreciated!
Here there is written that non listed attributes are passed to
mkPoetryApplication wraps it). So you could try passing
propagatedBuildInputs = [ pkgs.redis ];
Thanks @aciceri , that does work however the problem is that these packages are not installed when I install the python app. When I use
nix-store -qR the resulting package, I can see that it has a dependency on
redis as expected.
However, when I install the package using nix profile install (I am using nix flakes), the redis package is not made available in the path.
Is there something else which needs to be done to make redis available in the path?
EDIT: I would like to point out that I do get access to these in the dev shell environment. So perhaps there are gaps in my understanding of nix. When I enter the dev-shell using
nix develop, I can see redis is added to the path. Both the
mkShell are using
propagatedBuildInputs as per @aciceri 's reply above.
I think I understand what I was missing then. Please correct me if I am wrong, but adding a package as dependency doesn’t necessarily mean its made available at runtime or is added to the path.
I had to use
makeWrapper to add these packages to the path so they are available to my python application. Is it the recommended way of achieving this?
I think makeWrapper is a fine solution.
Essentially it means you are passing the redis dependency through the
PATH environment variable, but you could also decide to pass it in a different way:
- through a config file for your application
- by replacing the redis path in the code directly at build time
- by using another environment variable
The reason to do it like that is that it’s more hermetic, only the code which uses redis will see it, while using PATH/makeWrapper any subprocess of the application will see redis.