You probably want to omit the -p python38Packages.python. -p 'python38.withPackages (ps: with ps; [ ps.cadquery2.pythonocc-core-cadquery python six ])' should give you a python executable which is properly wrapped.
Before posting I tried that a well. Would have been nice if it were that simple.The question is more like should I add PYTHONPATH everywhere or try to fix it.
%nix-shell -p 'python38.withPackages (ps: with ps; [ ps.cadquery2.pythonocc-core-cadquery python six ])' --run 'python -c "import OCC"'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'OCC'