2023-02-04 17:04:06 +00:00
|
|
|
with (import <nixpkgs> {});
|
2024-01-18 01:58:46 +00:00
|
|
|
with python311Packages;
|
|
|
|
let
|
|
|
|
rapidfuzzStorePath = lib.getLib rapidfuzz;
|
|
|
|
qdarkstyleStorePath = lib.getLib qdarkstyle;
|
2024-01-23 21:50:03 +00:00
|
|
|
qtpyStorePath = lib.getLib qtpy;
|
2024-01-18 01:58:46 +00:00
|
|
|
pyqt5StorePath = lib.getLib pyqt5;
|
|
|
|
pyqt5SipStorePath = lib.getLib pyqt5_sip;
|
|
|
|
in
|
2023-02-04 17:04:06 +00:00
|
|
|
stdenv.mkDerivation {
|
2024-01-18 01:58:46 +00:00
|
|
|
name = "piker-poetry-shell-with-qt-fix";
|
2023-02-04 17:04:06 +00:00
|
|
|
buildInputs = [
|
|
|
|
# System requirements.
|
2024-01-18 01:58:46 +00:00
|
|
|
libsForQt5.qt5.qtbase
|
2023-06-13 19:23:46 +00:00
|
|
|
|
2024-01-18 01:58:46 +00:00
|
|
|
# Python requirements.
|
2023-09-11 16:34:29 +00:00
|
|
|
python311Full
|
2024-01-18 01:58:46 +00:00
|
|
|
poetry-core
|
|
|
|
rapidfuzz
|
|
|
|
qdarkstyle
|
2024-01-23 21:50:03 +00:00
|
|
|
qtpy
|
2024-01-18 01:58:46 +00:00
|
|
|
pyqt5
|
2023-02-04 17:04:06 +00:00
|
|
|
];
|
|
|
|
src = null;
|
|
|
|
shellHook = ''
|
2024-01-18 01:58:46 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
QTBASE_PATH="${qt5.qtbase.bin}/lib/qt-${qt5.qtbase.version}"
|
2023-02-04 17:04:06 +00:00
|
|
|
|
2024-01-18 01:58:46 +00:00
|
|
|
# Set the Qt plugin path
|
|
|
|
# export QT_DEBUG_PLUGINS=1
|
|
|
|
export QT_PLUGIN_PATH="$QTBASE_PATH/plugins"
|
|
|
|
export QT_QPA_PLATFORM_PLUGIN_PATH="$QT_PLUGIN_PATH/platforms"
|
2023-02-11 18:36:50 +00:00
|
|
|
|
2024-01-18 01:58:46 +00:00
|
|
|
# Maybe create venv & install deps
|
|
|
|
poetry install --with=nix-shell
|
|
|
|
|
|
|
|
# Use pyqt5 from System, patch activate script
|
|
|
|
ACTIVATE_SCRIPT_PATH="$(poetry env info --path)/bin/activate"
|
|
|
|
export RPDFUZZ_PATH="${rapidfuzzStorePath}/lib/python3.11/site-packages"
|
|
|
|
export QDRKSTYLE_PATH="${qdarkstyleStorePath}/lib/python3.11/site-packages"
|
2024-01-23 21:50:03 +00:00
|
|
|
export QTPY_PATH="${qtpyStorePath}/lib/python3.11/site-packages"
|
2024-01-18 01:58:46 +00:00
|
|
|
export PYQT5_PATH="${pyqt5StorePath}/lib/python3.11/site-packages"
|
|
|
|
export PYQT5_SIP_PATH="${pyqt5SipStorePath}/lib/python3.11/site-packages"
|
|
|
|
echo "rapidfuzz at: $RPDFUZZ_PATH"
|
|
|
|
echo "qdarkstyle at: $QDRKSTYLE_PATH"
|
2024-01-23 21:50:03 +00:00
|
|
|
echo "qtpy at: $QTPY_PATH"
|
2024-01-18 01:58:46 +00:00
|
|
|
echo "pyqt5 at: $PYQT5_PATH"
|
|
|
|
echo "pyqt5-sip at: $PYQT5_SIP_PATH"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
PATCH="export PYTHONPATH=\""
|
|
|
|
|
|
|
|
PATCH="$PATCH\$RPDFUZZ_PATH"
|
|
|
|
PATCH="$PATCH:\$QDRKSTYLE_PATH"
|
2024-01-23 21:50:03 +00:00
|
|
|
PATCH="$PATCH:\$QTPY_PATH"
|
2024-01-18 01:58:46 +00:00
|
|
|
PATCH="$PATCH:\$PYQT5_PATH"
|
|
|
|
PATCH="$PATCH:\$PYQT5_SIP_PATH"
|
|
|
|
|
|
|
|
PATCH="$PATCH\""
|
|
|
|
|
|
|
|
if grep -q "$PATCH" "$ACTIVATE_SCRIPT_PATH"; then
|
|
|
|
echo "venv is already patched."
|
|
|
|
else
|
|
|
|
echo "patching $ACTIVATE_SCRIPT_PATH to use pyqt5 from nixos..."
|
|
|
|
sed -i "\$i$PATCH" $ACTIVATE_SCRIPT_PATH
|
2023-02-11 18:36:50 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-18 01:58:46 +00:00
|
|
|
echo "qt plguin path: $QT_PLUGIN_PATH"
|
|
|
|
echo ""
|
|
|
|
|
2023-09-11 16:34:29 +00:00
|
|
|
poetry shell
|
2023-02-04 17:04:06 +00:00
|
|
|
'';
|
|
|
|
}
|