summary refs log tree commit diff
path: root/pkgs/applications/science/electronics/kicad/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/science/electronics/kicad/default.nix')
-rw-r--r--pkgs/applications/science/electronics/kicad/default.nix103
1 files changed, 52 insertions, 51 deletions
diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix
index f03a0a0ccef..2aa2686a29a 100644
--- a/pkgs/applications/science/electronics/kicad/default.nix
+++ b/pkgs/applications/science/electronics/kicad/default.nix
@@ -4,6 +4,7 @@
 , librsvg, cups
 
 , pname ? "kicad"
+, stable ? true
 , oceSupport ? false, opencascade
 , withOCCT ? true, opencascade-occt
 , ngspiceSupport ? true, libngspice
@@ -18,7 +19,6 @@ assert ngspiceSupport -> libngspice != null;
 with lib;
 let
 
-  stable = pname != "kicad-unstable";
   baseName = if (stable) then "kicad" else "kicad-unstable";
 
   versions =  import ./versions.nix;
@@ -35,17 +35,16 @@ let
   python = python3;
   wxPython = python3Packages.wxPython_4_0;
 
-  libraries = callPackages ./libraries.nix versionConfig.libVersion;
+in
+stdenv.mkDerivation rec {
+
+  passthru.libraries = callPackages ./libraries.nix versionConfig.libVersion;
   base = callPackage ./base.nix {
-    pname = baseName;
     inherit versions stable baseName;
     inherit wxGTK python wxPython;
     inherit debug withI18n withOCCT oceSupport ngspiceSupport scriptingSupport;
   };
 
-in
-stdenv.mkDerivation rec {
-
   inherit pname;
   version = versions.${baseName}.kicadVersion.version;
 
@@ -63,7 +62,7 @@ stdenv.mkDerivation rec {
 
   # wrapGAppsHook added the equivalent to ${base}/share
   # though i noticed no difference without it
-  makeWrapperArgs = [
+  makeWrapperArgs = with passthru.libraries; [
     "--prefix XDG_DATA_DIRS : ${base}/share"
     "--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share"
     "--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share"
@@ -73,47 +72,40 @@ stdenv.mkDerivation rec {
     "--prefix XDG_DATA_DIRS : ${cups}/share"
     "--prefix GIO_EXTRA_MODULES : ${gnome3.dconf}/lib/gio/modules"
 
-    "--set KISYSMOD ${libraries.footprints}/share/kicad/modules"
-    "--set KICAD_SYMBOL_DIR ${libraries.symbols}/share/kicad/library"
-    "--set KICAD_TEMPLATE_DIR ${libraries.templates}/share/kicad/template"
-    "--prefix KICAD_TEMPLATE_DIR : ${libraries.symbols}/share/kicad/template"
-    "--prefix KICAD_TEMPLATE_DIR : ${libraries.footprints}/share/kicad/template"
+    "--set KISYSMOD ${footprints}/share/kicad/modules"
+    "--set KICAD_SYMBOL_DIR ${symbols}/share/kicad/library"
+    "--set KICAD_TEMPLATE_DIR ${templates}/share/kicad/template"
+    "--prefix KICAD_TEMPLATE_DIR : ${symbols}/share/kicad/template"
+    "--prefix KICAD_TEMPLATE_DIR : ${footprints}/share/kicad/template"
   ]
-  ++ optionals (with3d) [ "--set KISYS3DMOD ${libraries.packages3d}/share/kicad/modules/packages3d" ]
+  ++ optionals (with3d) [ "--set KISYS3DMOD ${packages3d}/share/kicad/modules/packages3d" ]
   ++ optionals (ngspiceSupport) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
 
   # infinisil's workaround for #39493
   ++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]
   ;
 
-  # dunno why i have to add $makeWrapperArgs manually...
+  # why does $makeWrapperArgs have to be added explicitly?
   # $out and $program_PYTHONPATH don't exist when makeWrapperArgs gets set?
-  # not sure if anything has to be done with the other stuff in base/bin
-  # dxf2idf, idf2vrml, idfcyl, idfrect, kicad2step, kicad-ogltest
-  installPhase =
-    optionalString (scriptingSupport) '' buildPythonPath "${base} $pythonPath"
-    '' +
-    '' makeWrapper ${base}/bin/kicad $out/bin/kicad $makeWrapperArgs ''
-    + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
-    '' +
-    '' makeWrapper ${base}/bin/pcbnew $out/bin/pcbnew $makeWrapperArgs ''
-    + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
-    '' +
-    '' makeWrapper ${base}/bin/eeschema $out/bin/eeschema $makeWrapperArgs ''
-    + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
-    '' +
-    '' makeWrapper ${base}/bin/gerbview $out/bin/gerbview $makeWrapperArgs ''
-    + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
-    '' +
-    '' makeWrapper ${base}/bin/pcb_calculator $out/bin/pcb_calculator $makeWrapperArgs ''
-    + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
-    '' +
-    '' makeWrapper ${base}/bin/pl_editor $out/bin/pl_editor $makeWrapperArgs ''
-    + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
-    '' +
-    '' makeWrapper ${base}/bin/bitmap2component $out/bin/bitmap2component $makeWrapperArgs ''
-    + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
-    ''
+  # kicad-ogltest's source seems to indicate that crashing is expected behaviour...
+  installPhase = with lib;
+    let
+      tools = [ "kicad" "pcbnew" "eeschema" "gerbview" "pcb_calculator" "pl_editor" "bitmap2component" ];
+      utils = [ "dxf2idf" "idf2vrml" "idfcyl" "idfrect" "kicad2step" "kicad-ogltest" ];
+    in
+    ( concatStringsSep "\n"
+      ( flatten [
+        ( optionalString (scriptingSupport) "buildPythonPath \"${base} $pythonPath\" \n" )
+
+        # wrap each of the directly usable tools
+        ( map ( tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs"
+          + optionalString (scriptingSupport) " --set PYTHONPATH \"$program_PYTHONPATH\""
+            ) tools )
+
+        # link in the CLI utils
+        ( map ( util: "ln -s ${base}/bin/${util} $out/bin/${util}" ) utils )
+      ])
+    )
   ;
 
   # can't run this for each pname
@@ -123,10 +115,11 @@ stdenv.mkDerivation rec {
   # and can't git commit if this could be running in parallel with other scripts
   passthru.updateScript = [ ./update.sh "all" ];
 
-  meta = {
-    description = if (stable)
-      then "Open Source Electronics Design Automation Suite"
-      else "Open Source EDA Suite, Development Build";
+  meta = rec {
+    description = (if (stable)
+      then "Open Source Electronics Design Automation suite"
+      else "Open Source EDA suite, development build")
+      + (if (!with3d) then ", without 3D models" else "");
     homepage = "https://www.kicad-pcb.org/";
     longDescription = ''
       KiCad is an open source software suite for Electronic Design Automation.
@@ -134,12 +127,20 @@ stdenv.mkDerivation rec {
     '';
     license = licenses.agpl3;
     # berce seems inactive...
-    maintainers = with maintainers; [ evils kiwi berce ];
-    # kicad's cross-platform, not sure what to fill in here
-    platforms = with platforms; linux;
-  } // optionalAttrs with3d {
-    # We can't download the 3d models on Hydra - they are a ~1 GiB download and
-    # they occupy ~5 GiB in store.
-    hydraPlatforms = [];
+    maintainers = with stdenv.lib.maintainers; [ evils kiwi berce ];
+    # kicad is cross platform
+    platforms = stdenv.lib.platforms.all;
+    # despite that, nipkgs' wxGTK for darwin is "wxmac"
+    # and wxPython_4_0 does not account for this
+    # adjusting this package to downgrade to python2Packages.wxPython (wxPython 3),
+    # seems like more trouble than fixing wxPython_4_0 would be
+    # additionally, libngspice is marked as linux only, though it should support darwin
+
+    hydraPlatforms = if (with3d) then [ ] else platforms;
+    # We can't download the 3d models on Hydra,
+    # they are a ~1 GiB download and they occupy ~5 GiB in store.
+    # as long as the base and libraries (minus 3d) are build,
+    # this wrapper does not need to get built
+    # the kicad-*small "packages" cause this to happen
   };
 }