diff options
author | Gabriel Ebner <gebner@gebner.org> | 2020-01-03 20:14:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-03 20:14:07 +0100 |
commit | 3604ae8394483d6a5e68a026cec0032aa91e592c (patch) | |
tree | 0c66aa67b117ec1ab4dc30085b1fd8d2fbb53999 /pkgs/applications/science | |
parent | f4adb7c4d897485559c4f8b35f1be653e28e6893 (diff) | |
parent | e4786f3a1c75b6e2cc9b77063d0937801ce43b11 (diff) |
Merge pull request #74259 from Evils-Devils/kicad-unstable
kicad: cleanup, fix and update
Diffstat (limited to 'pkgs/applications/science')
4 files changed, 349 insertions, 158 deletions
diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix new file mode 100644 index 0000000000000..6bc6659622975 --- /dev/null +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -0,0 +1,130 @@ +{ lib, stdenv, fetchFromGitLab, cmake, libGLU, libGL, zlib, wxGTK +, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig +, doxygen, pcre, libpthreadstubs, libXdmcp, fetchpatch, lndir, callPackages + +, pname ? "kicad" +, stable ? true +, baseName ? "kicad" +, versions ? { } +, oceSupport ? false, opencascade +, withOCCT ? true, opencascade-occt +, ngspiceSupport ? true, libngspice +, scriptingSupport ? true, swig, python, pythonPackages, wxPython +, debug ? false, valgrind +, withI18n ? true +}: + +assert ngspiceSupport -> libngspice != null; + +with lib; +let + + versionConfig = versions.${baseName}; + baseVersion = "${versions.${baseName}.kicadVersion.version}"; + + # oce on aarch64 fails a test + withOCE = oceSupport && !stdenv.isAarch64; + withOCC = (withOCCT && !withOCE) || (oceSupport && stdenv.isAarch64); + + kicad-libraries = callPackages ./libraries.nix versionConfig.libVersion; + +in +stdenv.mkDerivation rec { + + inherit pname; + version = "base-${baseVersion}"; + + src = fetchFromGitLab ( + { + group = "kicad"; + owner = "code"; + repo = "kicad"; + rev = baseVersion; + } // versionConfig.kicadVersion.src + ); + + # quick fix for #72248 + # should be removed if a a more permanent fix is published + patches = [ + ( + fetchpatch { + url = "https://github.com/johnbeard/kicad/commit/dfb1318a3989e3d6f9f2ac33c924ca5030ea273b.patch"; + sha256 = "00ifd3fas8lid8svzh1w67xc8kyx89qidp7gm633r014j3kjkgcd"; + } + ) + ]; + + # tagged releases don't have "unknown" + # kicad nightlies use git describe --dirty + # nix removes .git, so its approximated here + postPatch = '' + substituteInPlace CMakeModules/KiCadVersion.cmake \ + --replace "unknown" ${builtins.substring 0 10 src.rev} + ''; + + makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ]; + + cmakeFlags = + optionals (scriptingSupport) [ + "-DKICAD_SCRIPTING=ON" + "-DKICAD_SCRIPTING_MODULES=ON" + "-DKICAD_SCRIPTING_PYTHON3=ON" + "-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON" + ] + ++ optional (!scriptingSupport) + "-DKICAD_SCRIPTING=OFF" + ++ optional (ngspiceSupport) "-DKICAD_SPICE=ON" + ++ optional (!withOCE) "-DKICAD_USE_OCE=OFF" + ++ optional (!withOCC) "-DKICAD_USE_OCC=OFF" + ++ optionals (withOCE) [ + "-DKICAD_USE_OCE=ON" + "-DOCE_DIR=${opencascade}" + ] + ++ optionals (withOCC) [ + "-DKICAD_USE_OCC=ON" + "-DOCC_INCLUDE_DIR=${opencascade-occt}/include/opencascade" + ] + ++ optionals (debug) [ + "-DCMAKE_BUILD_TYPE=Debug" + "-DKICAD_STDLIB_DEBUG=ON" + "-DKICAD_USE_VALGRIND=ON" + ] + ; + + nativeBuildInputs = [ cmake doxygen pkgconfig lndir ]; + + buildInputs = [ + libGLU libGL zlib libX11 wxGTK pcre libXdmcp gettext + glew glm libpthreadstubs cairo curl openssl boost + ] + ++ optionals (scriptingSupport) [ swig python wxPython ] + ++ optional (ngspiceSupport) libngspice + ++ optional (withOCE) opencascade + ++ optional (withOCC) opencascade-occt + ++ optional (debug) valgrind + ; + + # debug builds fail all but the python test + # 5.1.x fails the eeschema test + doInstallCheck = !debug && !stable; + installCheckTarget = "test"; + + dontStrip = debug; + + postInstall = optional (withI18n) '' + mkdir -p $out/share + lndir ${kicad-libraries.i18n}/share $out/share + ''; + + meta = { + description = "Just the built source without the libraries"; + longDescription = '' + Just the build products, optionally with the i18n linked in + the libraries are passed via an env var in the wrapper, default.nix + ''; + homepage = "https://www.kicad-pcb.org/"; + license = licenses.agpl3; + maintainers = with maintainers; [ evils kiwi berce ]; + platforms = with platforms; linux; + }; +} diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index 6b0c998d751a1..47222fe4a966d 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -1,121 +1,175 @@ -{ wxGTK, lib, stdenv, fetchurl, fetchFromGitHub, cmake, libGLU, libGL, zlib -, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig -, doxygen, pcre, libpthreadstubs, libXdmcp -, wrapGAppsHook -, oceSupport ? true, opencascade +{ lib, stdenv, gnome3, pkgs, wxGTK30, wxGTK31 +, gsettings-desktop-schemas, hicolor-icon-theme +, callPackage, callPackages +, librsvg, cups + +, pname ? "kicad" +, oceSupport ? false, opencascade +, withOCCT ? true, opencascade-occt , ngspiceSupport ? true, libngspice -, swig, python, pythonPackages -, lndir +, scriptingSupport ? true, swig, python3, python3Packages +, debug ? false, valgrind +, with3d ? true +, withI18n ? true }: assert ngspiceSupport -> libngspice != null; with lib; let - mkLib = version: name: sha256: attrs: stdenv.mkDerivation ({ - name = "kicad-${name}-${version}"; - src = fetchFromGitHub { - owner = "KiCad"; - repo = "kicad-${name}"; - rev = version; - inherit sha256 name; - }; - nativeBuildInputs = [ - cmake - ]; - } // attrs); - -in stdenv.mkDerivation rec { - pname = "kicad"; - series = "5.0"; - version = "5.1.4"; - - src = fetchurl { - url = "https://launchpad.net/kicad/${series}/${version}/+download/kicad-${version}.tar.xz"; - sha256 = "1r60dgh6aalbpq1wsmpyxkz0nn4ck8ydfdjcrblpl69k5rks5k2j"; - }; - postPatch = '' - substituteInPlace CMakeModules/KiCadVersion.cmake \ - --replace no-vcs-found ${version} - ''; - - cmakeFlags = [ - "-DKICAD_SCRIPTING=ON" - "-DKICAD_SCRIPTING_MODULES=ON" - "-DKICAD_SCRIPTING_WXPYTHON=ON" - # nix installs wxPython headers in wxPython package, not in wxwidget - # as assumed. We explicitely set the header location. - "-DCMAKE_CXX_FLAGS=-I${pythonPackages.wxPython}/include/wx-3.0" - "-DwxPYTHON_INCLUDE_DIRS=${pythonPackages.wxPython}/include/wx-3.0" - ] ++ optionals (oceSupport) [ "-DKICAD_USE_OCE=ON" "-DOCE_DIR=${opencascade}" ] - ++ optional (ngspiceSupport) "-DKICAD_SPICE=ON"; - - nativeBuildInputs = [ - cmake - doxygen - pkgconfig - wrapGAppsHook - pythonPackages.wrapPython - lndir - ]; - pythonPath = [ pythonPackages.wxPython ]; - propagatedBuildInputs = [ pythonPackages.wxPython ]; - - buildInputs = [ - libGLU libGL zlib libX11 wxGTK pcre libXdmcp glew glm libpthreadstubs - cairo curl openssl boost - swig (python.withPackages (ps: with ps; [ wxPython ])) - ] ++ optional (oceSupport) opencascade - ++ optional (ngspiceSupport) libngspice; - - # this breaks other applications in kicad - dontWrapGApps = true; - - passthru = { - i18n = mkLib version "i18n" "1dk7wis4cncmihl8fnic3jyhqcdzpifchzsp7hmf214h0vp199zr" { - buildInputs = [ - gettext - ]; - meta.license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 - }; - symbols = mkLib version "symbols" "1lna4xlvzrxif3569pkp6mrg7fj62z3a3ri5j97lnmnnzhiddnh3" { - meta.license = licenses.cc-by-sa-40; - }; - footprints = mkLib version "footprints" "0c0kcywxlaihzzwp9bi0dsr2v9j46zcdr85xmfpivmrk19apss6a" { - meta.license = licenses.cc-by-sa-40; - }; - templates = mkLib version "templates" "1bagb0b94cjh7zp9z0h23b60j45kwxbsbb7b2bdk98dmph8lmzbb" { - meta.license = licenses.cc-by-sa-40; + stable = pname != "kicad-unstable"; + baseName = if (stable) then "kicad" else "kicad-unstable"; + + versions = { + "kicad" = { + kicadVersion = { + version = "5.1.5"; + src.sha256 = "15h3rwisjss3fdc9bam9n2wq94slhacc3fbg14bnzf4n5agsnv5b"; + }; + libVersion = { + version = "5.1.5"; + libSources = { + i18n.sha256 = "1rfpifl8vky1gba2angizlb2n7mwmsiai3r6ip6qma60wdj8sbd3"; + symbols.sha256 = "048b07ffsaav1ssrchw2p870lvb4rsyb5vnniy670k7q9p16qq6h"; + templates.sha256 = "0cs3bm3zb5ngw5ldn0lzw5bvqm4kvcidyrn76438alffwiz2b15g"; + footprints.sha256 = "1c4whgn14qhz4yqkl46w13p6rpv1k0hsc9s9h9368fxfcz9knb2j"; + packages3d.sha256 = "0cff2ms1bsw530kqb1fr1m2pjixyxzwa81mxgac3qpbcf8fnpvaz"; + }; + }; }; - packages3d = mkLib version "packages3d" "0h2qjj8vf33jz6jhqdz90c80h5i1ydgfqnns7rn0fqphlnscb45g" { - hydraPlatforms = []; # this is a ~1 GiB download, occupies ~5 GiB in store - meta.license = licenses.cc-by-sa-40; + "kicad-unstable" = { + kicadVersion = { + version = "2019-12-31"; + src = { + rev = "eaaa4eb63acb289047dfbb6cc275579dea58f12b"; + sha256 = "1v2hf2slphjdh14y56pmzlpi6mqidrd8198if1fi0cch72v37zch"; + }; + }; + libVersion = { + version = "unstable"; + libSources = { + i18n.rev = "e7439fd76f27cfc26e269c4e6c4d56245345c28b"; + i18n.sha256 = "1nqm1kx5b4f7s0f9q8bg4rdhqnp0128yp6bgnrkia1kwmfnf5gmy"; + symbols.rev = "1bc5ff11c76bcbfda227e534b0acf737edddde8f"; + symbols.sha256 = "05kv93790wi4dpbn2488p587b83yz1zw9h62lkv41h7vn2r1mmb7"; + templates.rev = "0c0490897f803ab8b7c3dad438b7eb1f80e0417c"; + templates.sha256 = "0cs3bm3zb5ngw5ldn0lzw5bvqm4kvcidyrn76438alffwiz2b15g"; + footprints.rev = "454126c125edd3fa8633f301421a7d9c4de61b77"; + footprints.sha256 = "00nli4kx2i68bk852rivbirzcgpsdlpdk34g1q892952jsbh7fy6"; + packages3d.rev = "c2b92a411adc93ddeeed74b36b542e1057f81a2a"; + packages3d.sha256 = "05znc6y2lc31iafspg308cxdda94zg6c7mwslmys76npih1pb8qc"; + }; + }; }; }; + versionConfig = versions.${baseName}; + + wxGTK = if (stable) + # wxGTK3x may default to withGtk2 = false, see #73145 + then wxGTK30.override { withGtk2 = false; } + # wxGTK31 currently introduces an issue with opening the python interpreter in pcbnew + # but brings high DPI support? + else wxGTK31.override { withGtk2 = false; }; + + pythonPackages = python3Packages; + python = python3; + wxPython = python3Packages.wxPython_4_0; + + kicad-libraries = callPackages ./libraries.nix versionConfig.libVersion; + kicad-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; + + src = kicad-base; + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + dontFixup = true; + + pythonPath = optionals (scriptingSupport) + [ wxPython pythonPackages.six ]; + + nativeBuildInputs = optionals (scriptingSupport) + [ pythonPackages.wrapPython ]; - modules = with passthru; [ i18n symbols footprints templates ]; + # wrapGAppsHook added the equivalent to ${kicad-base}/share + # though i noticed no difference without it + makeWrapperArgs = [ + "--prefix XDG_DATA_DIRS : ${kicad-base}/share" + "--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share" + "--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share" + "--prefix XDG_DATA_DIRS : ${wxGTK.gtk}/share/gsettings-schemas/${wxGTK.gtk.name}" + "--prefix XDG_DATA_DIRS : ${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" + # wrapGAppsHook did these two as well, no idea if it matters... + "--prefix XDG_DATA_DIRS : ${cups}/share" + "--prefix GIO_EXTRA_MODULES : ${gnome3.dconf}/lib/gio/modules" - postInstall = '' - mkdir -p $out/share - for module in $modules; do - lndir $module/share $out/share - done - ''; + "--set KISYSMOD ${kicad-libraries.footprints}/share/kicad/modules" + "--set KICAD_SYMBOL_DIR ${kicad-libraries.symbols}/share/kicad/library" + "--set KICAD_TEMPLATE_DIR ${kicad-libraries.templates}/share/kicad/template" + "--prefix KICAD_TEMPLATE_DIR : ${kicad-libraries.symbols}/share/kicad/template" + "--prefix KICAD_TEMPLATE_DIR : ${kicad-libraries.footprints}/share/kicad/template" + ] + ++ optionals (with3d) [ "--set KISYS3DMOD ${kicad-libraries.packages3d}/share/kicad/modules/packages3d" ] + ++ optionals (ngspiceSupport) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ] - preFixup = '' - buildPythonPath "$out $pythonPath" - gappsWrapperArgs+=(--set PYTHONPATH "$program_PYTHONPATH") + # infinisil's workaround for #39493 + ++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ] + ; - wrapGApp "$out/bin/kicad" --prefix LD_LIBRARY_PATH : "${libngspice}/lib" - ''; + # dunno why i have to add $makeWrapperArgs manually... + # $out and $program_PYTHONPATH don't exist when makeWrapperArgs gets set? + # not sure if anything has to be done with the other stuff in kicad-base/bin + # dxf2idf, idf2vrml, idfcyl, idfrect, kicad2step, kicad-ogltest + installPhase = + optionalString (scriptingSupport) '' buildPythonPath "${kicad-base} $pythonPath" + '' + + '' makeWrapper ${kicad-base}/bin/kicad $out/bin/kicad $makeWrapperArgs '' + + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + '' + + '' makeWrapper ${kicad-base}/bin/pcbnew $out/bin/pcbnew $makeWrapperArgs '' + + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + '' + + '' makeWrapper ${kicad-base}/bin/eeschema $out/bin/eeschema $makeWrapperArgs '' + + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + '' + + '' makeWrapper ${kicad-base}/bin/gerbview $out/bin/gerbview $makeWrapperArgs '' + + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + '' + + '' makeWrapper ${kicad-base}/bin/pcb_calculator $out/bin/pcb_calculator $makeWrapperArgs '' + + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + '' + + '' makeWrapper ${kicad-base}/bin/pl_editor $out/bin/pl_editor $makeWrapperArgs '' + + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + '' + + '' makeWrapper ${kicad-base}/bin/bitmap2component $out/bin/bitmap2component $makeWrapperArgs '' + + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + '' + ; meta = { - description = "Free Software EDA Suite"; - homepage = http://www.kicad-pcb.org/; - license = licenses.gpl2; - maintainers = with maintainers; [ berce ]; + description = if (stable) + then "Open Source Electronics Design Automation Suite" + else "Open Source EDA Suite, Development Build"; + homepage = "https://www.kicad-pcb.org/"; + longDescription = '' + KiCad is an open source software suite for Electronic Design Automation. + The Programs handle Schematic Capture, and PCB Layout with Gerber output. + ''; + 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; - broken = stdenv.isAarch64; }; } diff --git a/pkgs/applications/science/electronics/kicad/libraries.nix b/pkgs/applications/science/electronics/kicad/libraries.nix new file mode 100644 index 0000000000000..53e190d2749b3 --- /dev/null +++ b/pkgs/applications/science/electronics/kicad/libraries.nix @@ -0,0 +1,64 @@ +{ lib, stdenv, cmake, gettext +, fetchFromGitHub, fetchFromGitLab +, version, libSources +}: + +# callPackage libraries { +# version = "unstable"; +# libs.symbols = { +# rev = "09f9.."; +# sha256 = "..."; +# }; +# }; +with lib; +let + mkLib = name: attrs: + stdenv.mkDerivation ( + { + pname = "kicad-${name}"; + version = "${version}"; + src = fetchFromGitHub ( + { + owner = "KiCad"; + repo = "kicad-${name}"; + rev = version; + inherit name; + } // (libSources.${name} or { }) + ); + nativeBuildInputs = [ cmake ]; + meta.license = licenses.cc-by-sa-40; + } // attrs + ); +in +{ + symbols = mkLib "symbols" { }; + templates = mkLib "templates" { }; + footprints = mkLib "footprints" { }; + packages3d = mkLib "packages3d" { + hydraPlatforms = []; # this is a ~1 GiB download, occupies ~5 GiB in store + }; + + # i18n is a special case, not actually a library + # more a part of kicad proper, but also optional and separate + # since their move to gitlab they're keeping it in a separate path + # kicad has no way to find i18n except through a path relative to its install path + # therefore this is being linked into ${kicad-base}/share/ + # and defined here to make use of the rev & sha256's brought here for the libs + i18n = let name = "i18n"; in + stdenv.mkDerivation { + pname = "kicad-${name}"; + version = "${version}"; + src = fetchFromGitLab ( + { + group = "kicad"; + owner = "code"; + repo = "kicad-${name}"; + rev = version; + inherit name; + } // (libSources.${name} or { }) + ); + buildInputs = [ gettext ]; + nativeBuildInputs = [ cmake ]; + meta.license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 + }; +} diff --git a/pkgs/applications/science/electronics/kicad/unstable.nix b/pkgs/applications/science/electronics/kicad/unstable.nix deleted file mode 100644 index df0d9932b8a0a..0000000000000 --- a/pkgs/applications/science/electronics/kicad/unstable.nix +++ /dev/null @@ -1,57 +0,0 @@ -{ wxGTK, lib, stdenv, fetchFromGitHub, cmake, libGLU, libGL, zlib -, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig -, doxygen, pcre, libpthreadstubs, libXdmcp - -, oceSupport ? true, opencascade -, ngspiceSupport ? true, libngspice -, scriptingSupport ? true, swig, python, wxPython -}: - -assert ngspiceSupport -> libngspice != null; - -with lib; -stdenv.mkDerivation rec { - pname = "kicad-unstable"; - version = "2018-06-12"; - - src = fetchFromGitHub { - owner = "KICad"; - repo = "kicad-source-mirror"; - rev = "bc7bd107d980da147ad515aeae0469ddd55c2368"; - sha256 = "11nsx52pd3jr2wbzr11glmcs1a9r7z1mqkqx6yvlm0awbgd8qlv8"; - }; - - postPatch = '' - substituteInPlace CMakeModules/KiCadVersion.cmake \ - --replace no-vcs-found ${version} - ''; - - cmakeFlags = - optionals (oceSupport) [ "-DKICAD_USE_OCE=ON" "-DOCE_DIR=${opencascade}" ] - ++ optional (ngspiceSupport) "-DKICAD_SPICE=ON" - ++ optionals (scriptingSupport) [ - "-DKICAD_SCRIPTING=ON" - "-DKICAD_SCRIPTING_MODULES=ON" - "-DKICAD_SCRIPTING_WXPYTHON=ON" - # nix installs wxPython headers in wxPython package, not in wxwidget - # as assumed. We explicitely set the header location. - "-DCMAKE_CXX_FLAGS=-I${wxPython}/include/wx-3.0" - ]; - - nativeBuildInputs = [ cmake doxygen pkgconfig ]; - buildInputs = [ - libGLU libGL zlib libX11 wxGTK pcre libXdmcp gettext glew glm libpthreadstubs - cairo curl openssl boost - ] ++ optional (oceSupport) opencascade - ++ optional (ngspiceSupport) libngspice - ++ optionals (scriptingSupport) [ swig python wxPython ]; - - meta = { - description = "Free Software EDA Suite, Nightly Development Build"; - homepage = http://www.kicad-pcb.org/; - license = licenses.gpl2; - maintainers = with maintainers; [ berce ]; - platforms = with platforms; linux; - broken = true; - }; -} |