about summary refs log tree commit diff
path: root/pkgs/development/python-modules/uxsim/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/uxsim/default.nix')
-rw-r--r--pkgs/development/python-modules/uxsim/default.nix64
1 files changed, 64 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/uxsim/default.nix b/pkgs/development/python-modules/uxsim/default.nix
new file mode 100644
index 0000000000000..675e92a1de315
--- /dev/null
+++ b/pkgs/development/python-modules/uxsim/default.nix
@@ -0,0 +1,64 @@
+{
+  lib,
+  buildPythonPackage,
+  fetchFromGitHub,
+  setuptools,
+  wheel,
+  qt5,
+  python,
+  dill,
+  matplotlib,
+  numpy,
+  pandas,
+  pillow,
+  pyqt5,
+  scipy,
+  tqdm,
+}:
+buildPythonPackage rec {
+  pname = "uxsim";
+  version = "1.3.0";
+  pyproject = true;
+
+  src = fetchFromGitHub {
+    owner = "toruseo";
+    repo = "UXsim";
+    rev = "refs/tags/v${version}";
+    hash = "sha256-2lN2Cu0XXiYdLiE7phpGqhkBDjkmxLJt4ILb6ORWdCI=";
+  };
+
+  patches = [ ./add-qt-plugin-path-to-env.patch ];
+
+  nativeBuildInputs = [
+    setuptools
+    wheel
+  ];
+
+  propagatedBuildInputs = [
+    dill
+    matplotlib
+    numpy
+    pandas
+    pillow
+    pyqt5
+    scipy
+    tqdm
+  ];
+
+  pythonImportsCheck = [ "uxsim" ];
+
+  # QT_PLUGIN_PATH is required to be set for the program to produce its images
+  # our patch sets it to $NIX_QT_PLUGIN_PATH if QT_PLUGIN_PATH is not set
+  # and here we replace this string with the actual path to qt plugins
+  postInstall = ''
+    substituteInPlace $out/${python.sitePackages}/uxsim/__init__.py \
+      --replace-fail '$NIX_QT_PLUGIN_PATH' '${qt5.qtbase.bin}/${qt5.qtbase.qtPluginPrefix}'
+  '';
+
+  meta = with lib; {
+    description = "Vehicular traffic flow simulator in road network, written in pure Python";
+    homepage = "https://github.com/toruseo/UXsim";
+    license = licenses.mit;
+    maintainers = with maintainers; [ vinnymeller ];
+  };
+}