This works in poetry2nix.mkPoetryEnv, it might work in python3.withPackages too.
poetry2nix.mkPoetryEnv
python3.withPackages