From 3d4d80220a834145a1e31e7285ecda0c5aaa24a4 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 16 Aug 2023 22:11:23 -0700 Subject: [PATCH 1/8] Add jfly to maintainers list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rohit Co-authored-by: Jeremy Fleischman Co-authored-by: Shahar "Dawn" Or Co-authored-by: Alejandro Sanchez Medina Co-authored-by: Matúš Ferech --- maintainers/maintainer-list.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 911f71a2cf05..9cbeda79bf1f 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -8295,6 +8295,15 @@ githubId = 18501; name = "Julien Langlois"; }; + jfly = { + name = "Jeremy Fleischman"; + email = "jeremyfleischman@gmail.com"; + github = "jfly"; + githubId = 277474; + keys = [{ + fingerprint = "F1F1 3395 8E8E 9CC4 D9FC 9647 1931 9CD8 416A 642B"; + }]; + }; jfrankenau = { email = "johannes@frankenau.net"; github = "jfrankenau"; From c0210aa307f47aa9f4ee125df99bbb6833b191fb Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 16 Aug 2023 22:11:54 -0700 Subject: [PATCH 2/8] Add matusf to maintainers list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rohit Co-authored-by: Jeremy Fleischman Co-authored-by: Shahar "Dawn" Or Co-authored-by: Alejandro Sanchez Medina Co-authored-by: Matúš Ferech --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 9cbeda79bf1f..0c410d2e362a 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -11218,6 +11218,12 @@ githubId = 11810057; name = "Matt Snider"; }; + matusf = { + email = "matus.ferech@gmail.com"; + github = "matusf"; + githubId = 18228995; + name = "Matúš Ferech"; + }; maurer = { email = "matthew.r.maurer+nix@gmail.com"; github = "maurer"; From 58a5da1346aa62f5f1be41b71a659f34840ed2d5 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 16 Aug 2023 22:12:48 -0700 Subject: [PATCH 3/8] python310Packages.euclid3,python311Packages.euclid3: init at 0.01 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rohit Co-authored-by: Jeremy Fleischman Co-authored-by: Shahar "Dawn" Or Co-authored-by: Alejandro Sanchez Medina Co-authored-by: Matúš Ferech --- .../python-modules/euclid3/default.nix | 25 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 pkgs/development/python-modules/euclid3/default.nix diff --git a/pkgs/development/python-modules/euclid3/default.nix b/pkgs/development/python-modules/euclid3/default.nix new file mode 100644 index 000000000000..3d723eca5658 --- /dev/null +++ b/pkgs/development/python-modules/euclid3/default.nix @@ -0,0 +1,25 @@ +{ buildPythonPackage +, lib +, fetchPypi +}: +buildPythonPackage rec { + pname = "euclid3"; + version = "0.01"; + format = "setuptools"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-JbgnpXrb/Zo/qGJeQ6vD6Qf2HeYiND5+U4SC75tG/Qs="; + }; + + pythonImportsCheck = [ + "euclid3" + ]; + + meta = with lib; { + description = "2D and 3D vector, matrix, quaternion and geometry module."; + homepage = "http://code.google.com/p/pyeuclid/"; + license = licenses.lgpl21Plus; + maintainers = with maintainers; [ jfly matusf ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 922e5a1b792e..267ecdfa333d 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3657,6 +3657,8 @@ self: super: with self; { et-xmlfile = callPackage ../development/python-modules/et-xmlfile { }; + euclid3 = callPackage ../development/python-modules/euclid3 { }; + eufylife-ble-client = callPackage ../development/python-modules/eufylife-ble-client { }; evaluate = callPackage ../development/python-modules/evaluate { }; From 0baca7e30ea4f7043814bca765b01c17781308c9 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 16 Aug 2023 22:15:42 -0700 Subject: [PATCH 4/8] python310Packages.pcbnew-transition,python311Packages.pcbnew-transition: init at 0.3.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rohit Co-authored-by: Jeremy Fleischman Co-authored-by: Shahar "Dawn" Or Co-authored-by: Alejandro Sanchez Medina Co-authored-by: Matúš Ferech --- .../pcbnew-transition/default.nix | 39 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 41 insertions(+) create mode 100644 pkgs/development/python-modules/pcbnew-transition/default.nix diff --git a/pkgs/development/python-modules/pcbnew-transition/default.nix b/pkgs/development/python-modules/pcbnew-transition/default.nix new file mode 100644 index 000000000000..2ac478308cda --- /dev/null +++ b/pkgs/development/python-modules/pcbnew-transition/default.nix @@ -0,0 +1,39 @@ +{ pythonOlder +, buildPythonPackage +, fetchPypi +, lib +, kicad +, versioneer +}: +buildPythonPackage rec { + pname = "pcbnewTransition"; + version = "0.3.4"; + format = "setuptools"; + + disabled = pythonOlder "3.7"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-3CJUG1kd63Lg0r9HpJRIvttHS5s2EuZRoxeXrqsJ/kQ="; + }; + + propagatedBuildInputs = [ + kicad + ]; + + nativeBuildInputs = [ + versioneer + ]; + + pythonImportsCheck = [ + "pcbnewTransition" + ]; + + meta = with lib; { + description = "Library that allows you to support both, KiCad 5, 6 and 7 in your plugins"; + homepage = "https://github.com/yaqwsx/pcbnewTransition"; + changelog = "https://github.com/yaqwsx/pcbnewTransition/releases/tag/v${version}"; + license = licenses.mit; + maintainers = with maintainers; [ jfly matusf ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 267ecdfa333d..0edd5a109910 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8845,6 +8845,8 @@ self: super: with self; { inherit (pkgs) libpcap; # Avoid confusion with python package of the same name }; + pcbnew-transition = callPackage ../development/python-modules/pcbnew-transition { }; + pcodedmp = callPackage ../development/python-modules/pcodedmp { }; pcpp = callPackage ../development/python-modules/pcpp { }; From 82056f0fc3649935e6938bd6dc24f1e158f53cb4 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 16 Aug 2023 22:16:39 -0700 Subject: [PATCH 5/8] python310Packages.pybars3,python311Packages.pybars3: init at 0.9.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rohit Co-authored-by: Jeremy Fleischman Co-authored-by: Shahar "Dawn" Or Co-authored-by: Alejandro Sanchez Medina Co-authored-by: Matúš Ferech --- .../python-modules/pybars3/default.nix | 38 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 40 insertions(+) create mode 100644 pkgs/development/python-modules/pybars3/default.nix diff --git a/pkgs/development/python-modules/pybars3/default.nix b/pkgs/development/python-modules/pybars3/default.nix new file mode 100644 index 000000000000..ad7294fd6358 --- /dev/null +++ b/pkgs/development/python-modules/pybars3/default.nix @@ -0,0 +1,38 @@ +{ python3 +, fetchPypi +, lib +, pymeta3 +, buildPythonPackage +}: +buildPythonPackage rec { + pname = "pybars3"; + version = "0.9.7"; + format = "setuptools"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-ashH6QXlO5xbk2rxEskQR14nv3Z/efRSjBb5rx7A4lI="; + }; + + propagatedBuildInputs = [ + pymeta3 + ]; + + checkPhase = '' + runHook preCheck + ${python3.interpreter} tests.py + runHook postCheck + ''; + + pythonImportsCheck = [ + "pybars" + ]; + + meta = with lib; { + description = "Handlebars.js template support for Python 3 and 2"; + homepage = "https://github.com/wbond/pybars3"; + changelog = "https://github.com/wbond/pybars3/releases/tag/${version}"; + license = licenses.lgpl3Only; + maintainers = with maintainers; [ jfly matusf ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0edd5a109910..4afb80c157ee 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -9013,6 +9013,8 @@ self: super: with self; { psrpcore = callPackage ../development/python-modules/psrpcore { }; + pybars3 = callPackage ../development/python-modules/pybars3 { }; + pypemicro = callPackage ../development/python-modules/pypemicro { }; pyprecice = callPackage ../development/python-modules/pyprecice { }; From 1f37289ea142d93d766387dbcab3de3bd7aa9143 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 16 Aug 2023 22:17:45 -0700 Subject: [PATCH 6/8] python310Packages.pymeta3,python311Packages.pymeta3: init at 0.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rohit Co-authored-by: Jeremy Fleischman Co-authored-by: Shahar "Dawn" Or Co-authored-by: Alejandro Sanchez Medina Co-authored-by: Matúš Ferech --- .../python-modules/pymeta3/default.nix | 29 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 pkgs/development/python-modules/pymeta3/default.nix diff --git a/pkgs/development/python-modules/pymeta3/default.nix b/pkgs/development/python-modules/pymeta3/default.nix new file mode 100644 index 000000000000..f0350c4153b7 --- /dev/null +++ b/pkgs/development/python-modules/pymeta3/default.nix @@ -0,0 +1,29 @@ +{ buildPythonPackage +, fetchPypi +, lib +}: +buildPythonPackage rec { + pname = "pymeta3"; + version = "0.5.1"; + format = "setuptools"; + + src = fetchPypi { + inherit version; + pname = "PyMeta3"; + hash = "sha256-GL2jJtmpu/WHv8DuC8loZJZNeLBnKIvPVdTZhoHQW8s="; + }; + + doCheck = false; # Tests do not support Python3 + + pythonImportsCheck = [ + "pymeta" + ]; + + meta = with lib; { + description = "Pattern-matching language based on OMeta for Python 3 and 2"; + homepage = "https://github.com/wbond/pymeta3"; + changelog = "https://github.com/wbond/pymeta3/releases/tag/${version}"; + license = licenses.mit; + maintainers = with maintainers; [ jfly matusf ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 4afb80c157ee..263e73cbd505 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -9015,6 +9015,8 @@ self: super: with self; { pybars3 = callPackage ../development/python-modules/pybars3 { }; + pymeta3 = callPackage ../development/python-modules/pymeta3 { }; + pypemicro = callPackage ../development/python-modules/pypemicro { }; pyprecice = callPackage ../development/python-modules/pyprecice { }; From 0650d380c765a8cc438051b7b1cf038d0901f7f7 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 16 Aug 2023 22:21:13 -0700 Subject: [PATCH 7/8] kikit: init at 1.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rohit Co-authored-by: Jeremy Fleischman Co-authored-by: Shahar "Dawn" Or Co-authored-by: Alejandro Sanchez Medina Co-authored-by: Matúš Ferech --- pkgs/by-name/ki/kikit/default.nix | 87 +++++++++++++++++++ pkgs/by-name/ki/kikit/package.nix | 2 + pkgs/by-name/ki/kikit/shapely/default.nix | 71 +++++++++++++++ .../ki/kikit/shapely/library-paths.patch | 31 +++++++ pkgs/by-name/ki/kikit/solidpython/default.nix | 66 ++++++++++++++ 5 files changed, 257 insertions(+) create mode 100644 pkgs/by-name/ki/kikit/default.nix create mode 100644 pkgs/by-name/ki/kikit/package.nix create mode 100644 pkgs/by-name/ki/kikit/shapely/default.nix create mode 100644 pkgs/by-name/ki/kikit/shapely/library-paths.patch create mode 100644 pkgs/by-name/ki/kikit/solidpython/default.nix diff --git a/pkgs/by-name/ki/kikit/default.nix b/pkgs/by-name/ki/kikit/default.nix new file mode 100644 index 000000000000..45209545aa3d --- /dev/null +++ b/pkgs/by-name/ki/kikit/default.nix @@ -0,0 +1,87 @@ +{ bc +, zip +, lib +, fetchFromGitHub +, bats +, buildPythonApplication +, pythonOlder +, callPackage +, kicad +, numpy +, click +, markdown2 +, pytestCheckHook +, commentjson +, wxPython_4_2 +, pcbnew-transition +, pybars3 +, versioneer +}: +let + solidpython = callPackage ./solidpython { }; + + # https://github.com/yaqwsx/KiKit/issues/574 + # copy-pasted from nixpkgs#8d8e62e74f511160a599471549a98bc9e4f4818d + shapely = callPackage ./shapely { }; +in +buildPythonApplication rec { + pname = "kikit"; + version = "1.3.0"; + format = "setuptools"; + + disabled = pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "yaqwsx"; + repo = "KiKit"; + rev = "v${version}"; + hash = "sha256-kDTPk/R3eZtm4DjoUV4tSQzjGQ9k8MKQedX4oUXYzeo="; + }; + + propagatedBuildInputs = [ + kicad + numpy + click + markdown2 + commentjson + # https://github.com/yaqwsx/KiKit/issues/575 + wxPython_4_2 + pcbnew-transition + pybars3 + shapely + # https://github.com/yaqwsx/KiKit/issues/576 + solidpython + ]; + + nativeBuildInputs = [ + versioneer + bc + zip + ]; + + nativeCheckInputs = [ + pytestCheckHook + bats + ]; + + pythonImportsCheck = [ + "kikit" + ]; + + preCheck = '' + export PATH=$PATH:$out/bin + + make test-system + + # pytest needs to run in a subdir. See https://github.com/yaqwsx/KiKit/blob/v1.3.0/Makefile#L43 + cd test/units + ''; + + meta = with lib; { + description = "Automation for KiCAD boards"; + homepage = "https://github.com/yaqwsx/KiKit/"; + changelog = "https://github.com/yaqwsx/KiKit/releases/tag/v${version}"; + maintainers = with maintainers; [ jfly matusf ]; + license = licenses.mit; + }; +} diff --git a/pkgs/by-name/ki/kikit/package.nix b/pkgs/by-name/ki/kikit/package.nix new file mode 100644 index 000000000000..5f1daa8aa5cd --- /dev/null +++ b/pkgs/by-name/ki/kikit/package.nix @@ -0,0 +1,2 @@ +{ python3 }: +(python3.pkgs.callPackage ./default.nix { }) diff --git a/pkgs/by-name/ki/kikit/shapely/default.nix b/pkgs/by-name/ki/kikit/shapely/default.nix new file mode 100644 index 000000000000..7f136a1338ad --- /dev/null +++ b/pkgs/by-name/ki/kikit/shapely/default.nix @@ -0,0 +1,71 @@ +{ lib +, stdenv +, buildPythonPackage +, fetchPypi +, substituteAll +, pythonOlder +, geos +, pytestCheckHook +, cython +, numpy +}: + +buildPythonPackage rec { + pname = "Shapely"; + version = "1.8.4"; + disabled = pythonOlder "3.6"; + + src = fetchPypi { + inherit pname version; + sha256 = "sha256-oZXlHKr6IYKR8suqP+9p/TNTyT7EtlsqRyLEz0DDGYw="; + }; + + nativeBuildInputs = [ + geos # for geos-config + cython + ]; + + propagatedBuildInputs = [ + numpy + ]; + + checkInputs = [ + pytestCheckHook + ]; + + # Environment variable used in shapely/_buildcfg.py + GEOS_LIBRARY_PATH = "${geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}"; + + patches = [ + # Patch to search form GOES .so/.dylib files in a Nix-aware way + (substituteAll { + src = ./library-paths.patch; + libgeos_c = GEOS_LIBRARY_PATH; + libc = lib.optionalString (!stdenv.isDarwin) "${stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}.6"; + }) + ]; + + preCheck = '' + rm -r shapely # prevent import of local shapely + ''; + + disabledTests = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ + # FIXME(lf-): these logging tests are broken, which is definitely our + # fault. I've tried figuring out the cause and failed. + # + # It is apparently some sandbox or no-sandbox related thing on macOS only + # though. + "test_error_handler_exception" + "test_error_handler" + "test_info_handler" + ]; + + pythonImportsCheck = [ "shapely" ]; + + meta = with lib; { + description = "Geometric objects, predicates, and operations"; + homepage = "https://pypi.python.org/pypi/Shapely/"; + license = with licenses; [ bsd3 ]; + maintainers = with maintainers; [ knedlsepp ]; + }; +} diff --git a/pkgs/by-name/ki/kikit/shapely/library-paths.patch b/pkgs/by-name/ki/kikit/shapely/library-paths.patch new file mode 100644 index 000000000000..12f93e757f9a --- /dev/null +++ b/pkgs/by-name/ki/kikit/shapely/library-paths.patch @@ -0,0 +1,31 @@ +diff --git a/shapely/geos.py b/shapely/geos.py +index 88c5f53..1ccd6e4 100644 +--- a/shapely/geos.py ++++ b/shapely/geos.py +@@ -96,6 +96,7 @@ if sys.platform.startswith('linux'): + alt_paths = [ + 'libgeos_c.so.1', + 'libgeos_c.so', ++ '@libgeos_c@', + ] + _lgeos = load_dll('geos_c', fallbacks=alt_paths) + +@@ -160,6 +161,7 @@ elif sys.platform == 'darwin': + "/usr/local/lib/libgeos_c.dylib", + # homebrew Apple Silicon + "/opt/homebrew/lib/libgeos_c.dylib", ++ "@libgeos_c@", + ] + _lgeos = load_dll('geos_c', fallbacks=alt_paths) + +diff --git a/tests/test_dlls.py b/tests/test_dlls.py +index c71da8e..c36262c 100644 +--- a/tests/test_dlls.py ++++ b/tests/test_dlls.py +@@ -18,4 +18,5 @@ class LoadingTestCase(unittest.TestCase): + '/opt/homebrew/lib/libgeos_c.dylib', # homebrew (macOS) + os.path.join(sys.prefix, "lib", "libgeos_c.so"), # anaconda (Linux) + 'libgeos_c.so.1', +- 'libgeos_c.so']) ++ 'libgeos_c.so', ++ '@libgeos_c@']) diff --git a/pkgs/by-name/ki/kikit/solidpython/default.nix b/pkgs/by-name/ki/kikit/solidpython/default.nix new file mode 100644 index 000000000000..c03637907a36 --- /dev/null +++ b/pkgs/by-name/ki/kikit/solidpython/default.nix @@ -0,0 +1,66 @@ +# SolidPython is an unmaintained library with old dependencies. +{ buildPythonPackage +, callPackage +, fetchFromGitHub +, fetchFromGitLab +, fetchpatch +, lib +, pythonRelaxDepsHook + +, poetry-core +, prettytable +, pypng +, ply +, setuptools +, euclid3 +}: +buildPythonPackage rec { + pname = "solidpython"; + version = "1.1.3"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "SolidCode"; + repo = "SolidPython"; + rev = "d962740d600c5dfd69458c4559fc416b9beab575"; + hash = "sha256-3fJta2a5c8hV9FPwKn5pj01aBtsCGSRCz3vvxR/5n0Q="; + }; + + nativeBuildInputs = [ + poetry-core + pythonRelaxDepsHook + ]; + + propagatedBuildInputs = [ + ply + setuptools + euclid3 + + prettytable + ]; + + pythonRelaxDeps = [ + # SolidPython has PrettyTable pinned to a hyper-specific version due to + # some ancient bug with Poetry. They aren't interested in unpinning because + # SolidPython v1 seems to be deprecated in favor of v2: + # https://github.com/SolidCode/SolidPython/issues/207 + "PrettyTable" + ]; + + pythonRemoveDeps = [ + # The pypng dependency is only used in an example script. + "pypng" + ]; + + pythonImportsCheck = [ + "solid" + ]; + + meta = with lib; { + description = "Python interface to the OpenSCAD declarative geometry language"; + homepage = "https://github.com/SolidCode/SolidPython"; + changelog = "https://github.com/SolidCode/SolidPython/releases/tag/v${version}"; + maintainers = with maintainers; [ jfly ]; + license = licenses.lgpl21Plus; + }; +} From d0bec347c4b29d84ddd901f31b7e4247a4c7a395 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Wed, 4 Oct 2023 14:02:27 +0700 Subject: [PATCH 8/8] kicadAddons.kikit,kicadAddons.kikit-library: init at 1.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a new kicadAddons package set, and a mechanism to override kicad to bundle addons. Co-authored-by: Rohit Co-authored-by: Jeremy Fleischman Co-authored-by: Shahar "Dawn" Or Co-authored-by: Alejandro Sanchez Medina Co-authored-by: Matúš Ferech --- .../electronics/kicad/addons/default.nix | 5 ++ .../electronics/kicad/addons/kikit.nix | 52 ++++++++++++++++++ .../science/electronics/kicad/base.nix | 2 + .../science/electronics/kicad/default.nix | 53 ++++++++++++++++++- .../kicad/runtime_stock_data_path.patch | 15 ++++++ pkgs/top-level/all-packages.nix | 2 + 6 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 pkgs/applications/science/electronics/kicad/addons/default.nix create mode 100644 pkgs/applications/science/electronics/kicad/addons/kikit.nix create mode 100644 pkgs/applications/science/electronics/kicad/runtime_stock_data_path.patch diff --git a/pkgs/applications/science/electronics/kicad/addons/default.nix b/pkgs/applications/science/electronics/kicad/addons/default.nix new file mode 100644 index 000000000000..5170e7efce36 --- /dev/null +++ b/pkgs/applications/science/electronics/kicad/addons/default.nix @@ -0,0 +1,5 @@ +{ kicad }: +{ + kikit = kicad.callPackage ./kikit.nix { addonName = "kikit"; }; + kikit-library = kicad.callPackage ./kikit.nix { addonName = "kikit-library"; }; +} diff --git a/pkgs/applications/science/electronics/kicad/addons/kikit.nix b/pkgs/applications/science/electronics/kicad/addons/kikit.nix new file mode 100644 index 000000000000..6e5fc5ad9678 --- /dev/null +++ b/pkgs/applications/science/electronics/kicad/addons/kikit.nix @@ -0,0 +1,52 @@ +# For building the multiple addons that are in the kikit repo. +{ stdenv +, bc +, kikit +, zip +, python3 +, addonName +, addonPath +}: +let + # This python is only used when building the package, it's not the python + # environment that will ultimately run the code packaged here. The python env defined + # in KiCad will import the python code packaged here when KiCad starts up. + python = python3.withPackages (ps: with ps; [ click ]); + kikit-module = python3.pkgs.toPythonModule (kikit.override { inherit python3; }); + + # The following different addons can be built from the same source. + targetSpecs = { + "kikit" = { + makeTarget = "pcm-kikit"; + resultZip = "pcm-kikit.zip"; + description = "KiCad plugin and a CLI tool to automate several tasks in a standard KiCad workflow"; + }; + "kikit-library" = { + makeTarget = "pcm-lib"; + resultZip = "pcm-kikit-lib.zip"; + description = "KiKit uses these symbols and footprints to annotate your boards (e.g., to place a tab in a panel)."; + }; + }; + targetSpec = targetSpecs.${addonName}; +in +stdenv.mkDerivation { + name = "kicadaddon-${addonName}"; + inherit (kikit-module) src version; + + nativeBuildInputs = [ python bc zip ]; + propagatedBuildInputs = [ kikit-module ]; + + buildPhase = '' + patchShebangs scripts/setJson.py + make ${targetSpec.makeTarget} + ''; + + installPhase = '' + mkdir $out + mv build/${targetSpec.resultZip} $out/${addonPath} + ''; + + meta = kikit-module.meta // { + description = targetSpec.description; + }; +} diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix index 3403e410cf85..a2e5bbe72a56 100644 --- a/pkgs/applications/science/electronics/kicad/base.nix +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -69,6 +69,8 @@ stdenv.mkDerivation rec { patches = [ # upstream issue 12941 (attempted to upstream, but appreciably unacceptable) ./writable.patch + # https://gitlab.com/kicad/code/kicad/-/issues/15687 + ./runtime_stock_data_path.patch ]; # tagged releases don't have "unknown" diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index a49c813036d3..c6c66839e4bc 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -1,4 +1,6 @@ { lib, stdenv +, runCommand +, newScope , fetchFromGitLab , gnome , dconf @@ -11,6 +13,8 @@ , callPackages , librsvg , cups +, unzip +, jq , pname ? "kicad" , stable ? true @@ -18,6 +22,7 @@ , libngspice , withScripting ? true , python3 +, addons ? [ ] , debug ? false , sanitizeAddress ? false , sanitizeThreads ? false @@ -27,6 +32,14 @@ , symlinkJoin }: +# `addons`: https://dev-docs.kicad.org/en/addons/ +# +# ```nix +# kicad = pkgs.kicad.override { +# addons = with pkgs.kicadAddons; [ kikit kikit-library ]; +# }; +# ``` + # The `srcs` parameter can be used to override the kicad source code # and all libraries, which are otherwise inaccessible # to overlays since most of the kicad build expression has been @@ -106,6 +119,32 @@ let wxGTK = wxGTK32; python = python3; wxPython = python.pkgs.wxPython_4_2; + addonPath = "addon.zip"; + addonsDrvs = map (pkg: pkg.override { inherit addonPath python3; }) addons; + + addonsJoined = + runCommand "addonsJoined" + { + inherit addonsDrvs; + nativeBuildInputs = [ unzip jq ]; + } '' + mkdir $out + + for pkg in $addonsDrvs; do + unzip $pkg/addon.zip -d unpacked + + folder_name=$(jq .identifier unpacked/metadata.json --raw-output | tr . _) + for d in unpacked/*; do + if [ -d "$d" ]; then + dest=$out/share/kicad/scripting/$(basename $d)/$folder_name + mkdir -p $(dirname $dest) + + mv $d $dest + fi + done + rm -r unpacked + done + ''; inherit (lib) concatStringsSep flatten optionalString optionals; in @@ -113,6 +152,7 @@ stdenv.mkDerivation rec { # Common libraries, referenced during runtime, via the wrapper. passthru.libraries = callPackages ./libraries.nix { inherit libSrc; }; + passthru.callPackage = newScope { inherit addonPath python3; }; base = callPackage ./base.nix { inherit stable baseName; inherit kicadSrc kicadVersion; @@ -131,7 +171,7 @@ stdenv.mkDerivation rec { dontFixup = true; pythonPath = optionals (withScripting) - [ wxPython python.pkgs.six python.pkgs.requests ]; + [ wxPython python.pkgs.six python.pkgs.requests ] ++ addonsDrvs; nativeBuildInputs = [ makeWrapper ] ++ optionals (withScripting) @@ -164,6 +204,17 @@ stdenv.mkDerivation rec { "--set-default KICAD7_SYMBOL_DIR ${symbols}/share/kicad/symbols" "--set-default KICAD7_TEMPLATE_DIR ${template_dir}" ] + ++ optionals (addons != [ ]) ( + let stockDataPath = symlinkJoin { + name = "kicad_stock_data_path"; + paths = [ + "${base}/share/kicad" + "${addonsJoined}/share/kicad" + ]; + }; + in + [ "--set-default NIX_KICAD7_STOCK_DATA_PATH ${stockDataPath}" ] + ) ++ optionals (with3d) [ "--set-default KICAD7_3DMODEL_DIR ${packages3d}/share/kicad/3dmodels" diff --git a/pkgs/applications/science/electronics/kicad/runtime_stock_data_path.patch b/pkgs/applications/science/electronics/kicad/runtime_stock_data_path.patch new file mode 100644 index 000000000000..16f7e493c623 --- /dev/null +++ b/pkgs/applications/science/electronics/kicad/runtime_stock_data_path.patch @@ -0,0 +1,15 @@ +diff --git a/common/paths.cpp b/common/paths.cpp +index a74cdd9..790cc58 100644 +--- a/common/paths.cpp ++++ b/common/paths.cpp +@@ -151,6 +151,10 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir ) + { + wxString path; + ++ if( wxGetEnv( wxT( "NIX_KICAD7_STOCK_DATA_PATH" ), &path ) ) { ++ return path; ++ } ++ + if( aRespectRunFromBuildDir && wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) + { + // Allow debugging from build dir by placing relevant files/folders in the build root diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ba0a724f56d6..f05d13560401 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -39768,6 +39768,8 @@ with pkgs; with3d = false; }; + kicadAddons = recurseIntoAttrs (callPackage ../applications/science/electronics/kicad/addons {}); + librepcb = libsForQt5.callPackage ../applications/science/electronics/librepcb { }; ngspice = libngspice.override {