Flakes: How to use poetry's virtualenv python executable?

I’m working on a project with Python, and I’m using poetry for the convenience of managing my dependencies. I’m using poetry shell in shellHook because I thought that that would enable all the scripts from the virtualenv, but it seems I’m mistaken:

2024-03-27 07:01:08,918 CST - ERROR - pylsp.plugins.flake8_lint - Error while running flake8 '/nix/store/sw7yq653d031bh7q04wy9j5kqgdaxfb7-python3-3.11.8-env/bin/python3.11: No module named flake8

My editor, Emacs, is using the python executable from the store, not from the virtualenv as I expect.

How do I use the python from the virtualenv?

Flake:

# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.9)
{

  # Flake inputs
  inputs = {
    pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
    flake-schemas.url =
      "https://flakehub.com/f/DeterminateSystems/flake-schemas/*.tar.gz";

    nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2311.*.tar.gz";
  };

  # Flake outputs that other flakes can use
  outputs = { self, flake-schemas, nixpkgs, pre-commit-hooks }:
    let
      # Helpers for producing system-specific outputs
      supportedSystems =
        [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" "aarch64-linux" ];
      forEachSupportedSystem = f:
        nixpkgs.lib.genAttrs supportedSystems (system:
          f {
            pkgs = import nixpkgs { inherit system; };
            inherit system;
          });
    in {
      # Schemas tell Nix about the structure of your flake's outputs
      schemas = flake-schemas.schemas;

      checks = forEachSupportedSystem ({ system, ... }: {
        pre-commit-check = pre-commit-hooks.lib.${system}.run {
          src = ./.;
          hooks = {
            # nix
            nixpkgs-fmt.enable = true;
            # python
            black.enable = true;
            isort.enable = true;
            mypy.enable = true;
            flake8.enable = true;
            # shell
            shfmt.enable = true;
            shellcheck.enable = true;
          };
        };
      });
      # Development environments
      devShells = forEachSupportedSystem ({ pkgs, ... }: {
        default = pkgs.mkShell {
          # Pinned packages available in the environment
          packages = with pkgs; [
            git
            nixpkgs-fmt
            poethepoet

            # ⚠ PySide y Shiboken son instalados por Nix, no por poetry
            (python311.withPackages (ps:
              with ps; [
                # interprete
                python

                # pyside
                pyside2
                shiboken2
                pyside2-tools
              ]))
          ];
          shellHook = ''
            poetry shell -n
          '';
        };
      });
    };
}

My pyproject.toml:

[tool.poetry]
name = "..."
version = "0.1.0"
description = "..."
authors = ["..."]
license = "GPL3"
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.11,<3.13"
poethepoet = "^0.25.0"
black = "^24.3.0"
flake8 = "^7.0.0"
pytest = "^8.1.1"
python-lsp-server = "^1.10.1"
pyls-flake8 = "^0.4.0"
pyls-isort = "^0.2.2"
pylsp-mypy = "^0.6.8"
python-lsp-black = "^2.0.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.mypy]
mypy_path = "src/stubs"

[[tool.mypy.overrides]]
module = ["PySide2.*"]
ignore_missing_imports = true

[tool.poe.tasks]
convert-ui = "scripts/convert_ui.sh ./ui ./src/ui"
mypy = "stubgen -o src/stubs src/ui"
run = "python app.py"

[flake8]
max-line-length = 88

[black]
line-length = 88