Trying to get core working on NixOS

Hello,

im trying to get core working on my Nixos system but when i try to run pio run it says that pyserial is not installed while it is

output:

Beast[~/GIT/Personal/esp32_test] > pio run   
Processing esp32dev (platform: espressif32; board: esp32dev; framework: espidf)
----------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.4.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-espidf @ 3.50101.230828 (5.1.1) 
 - tool-cmake @ 3.16.4 
 - tool-esptoolpy @ 1.40501.0 (4.5.1) 
 - tool-ninja @ 1.7.1 
 - tool-riscv32-esp-elf-gdb @ 12.1.0+20221002 
 - tool-xtensa-esp-elf-gdb @ 12.1.0+20221002 
 - toolchain-esp32ulp @ 1.23500.220830 (2.35.0) 
 - toolchain-xtensa-esp32 @ 12.2.0+20230208
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Building .pio/build/esp32dev/bootloader.bin
Pyserial is not installed for /nix/store/pzf6dnxg8gf04xazzjdwarm7s03cbrgz-python3-3.10.12/bin/python3.10. Check the README for installation instructions.
Traceback (most recent call last):
  File "/home/nicolaivds/.platformio/packages/tool-esptoolpy/esptool.py", line 31, in <module>
    import esptool
  File "/home/nicolaivds/.platformio/packages/tool-esptoolpy/esptool/__init__.py", line 41, in <module>
    from esptool.cmds import (
  File "/home/nicolaivds/.platformio/packages/tool-esptoolpy/esptool/cmds.py", line 14, in <module>
    from .bin_image import ELFFile, ImageSegment, LoadFirmwareImage
  File "/home/nicolaivds/.platformio/packages/tool-esptoolpy/esptool/bin_image.py", line 14, in <module>
    from .loader import ESPLoader
  File "/home/nicolaivds/.platformio/packages/tool-esptoolpy/esptool/loader.py", line 30, in <module>
    import serial
ModuleNotFoundError: No module named 'serial'
*** [.pio/build/esp32dev/bootloader.bin] Error 1
================================================ [FAILED] Took 3.20 seconds ================================================

here is my shell.nix file:

{ pkgs ? import <nixpkgs> {} }:
let
  my-python = pkgs.python3;
  my-python-packages = my-python.withPackages (ps: with ps; [
    pip
    setuptools
    pyserial
  ]);
in 
pkgs.mkShell {
  buildInputs = [
    my-python-packages
  ] ++ (with pkgs; [
    platformio-core
    esptool
  ]);

  shellHook = ''
    PYTHONPATH=${my-python-packages}/${my-python-packages.sitePackages}
  '';
}

i must say where the pio run command looks for pyserial is difrent from my $PYTHONPATH

Beast[~/GIT/Personal/esp32_test] > echo $PYTHONPATH
/nix/store/sl1ga1nap5lkz5is9gc45xvvyx7r6rcf-python3-3.10.12-env/lib/python3.10/site-packages

does any one have any idea what i am missing ?

i managed to fix this by installing pyserial to ~/.platformio/packages/tool-esptoolpy via this command pip install pyserial -t ~/.platformio/packages/tool-esptoolpy