From c61170168d7721ceaebb9a520a494c92dbe9a380 Mon Sep 17 00:00:00 2001 From: Evils Date: Tue, 26 Nov 2019 12:02:49 +0100 Subject: [PATCH] kicad: switch to best try from unstable and 5.1.5 make unstable use kicad-libraries still using a link in $out..., not sure that's a bad thing this allows setting that path in makeWrapperArgs can't use $out there kicad-with-packages3d -> kicad and kicad-small default to OCCT, OCE is outdated enforce OCCT on aarch64, where OCE is broken withOCE flag allows using OCE on non-aarch64 --- .../science/electronics/kicad/base.nix | 131 ++++++++++++++++++ .../science/electronics/kicad/default.nix | 8 +- .../science/electronics/kicad/libraries.nix | 50 +++++++ .../science/electronics/kicad/unstable.nix | 8 +- pkgs/top-level/aliases.nix | 1 + pkgs/top-level/all-packages.nix | 5 +- 6 files changed, 194 insertions(+), 9 deletions(-) create mode 100644 pkgs/applications/science/electronics/kicad/base.nix create mode 100644 pkgs/applications/science/electronics/kicad/libraries.nix diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix new file mode 100644 index 000000000000..adb2a418b6e5 --- /dev/null +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -0,0 +1,131 @@ +{ 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" + postPatch = optional (!stable) + '' + substituteInPlace CMakeModules/KiCadVersion.cmake \ + --replace "unknown" ${baseVersion} + ''; + + 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" + ] + ; + + pythonPath = + optionals (scriptingSupport) + [ wxPython pythonPackages.six ]; + + 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 ca5d7da29e0f..47dd1f084961 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -1,11 +1,11 @@ -{ lib, stdenv, fetchFromGitHub, cmake, libGLU_combined, zlib, wxGTK +{ lib, stdenv, fetchFromGitHub, cmake, libGLU, libGL, zlib, wxGTK , libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig , doxygen, pcre, libpthreadstubs, libXdmcp, makeWrapper, gnome3 , gsettings-desktop-schemas, librsvg, hicolor-icon-theme, lndir, cups , fetchpatch -, oceSupport ? true, opencascade -, withOCCT ? false, opencascade-occt +, oceSupport ? false, opencascade +, withOCCT ? true, opencascade-occt , ngspiceSupport ? true, libngspice , scriptingSupport ? true, swig, python, pythonPackages, wxPython , debug ? false, valgrind @@ -95,7 +95,7 @@ stdenv.mkDerivation rec { ; buildInputs = [ - libGLU_combined zlib libX11 wxGTK pcre libXdmcp gettext + libGLU libGL zlib libX11 wxGTK pcre libXdmcp gettext glew glm libpthreadstubs cairo curl openssl boost ] ++ optionals (scriptingSupport) [ swig python wxPython ] diff --git a/pkgs/applications/science/electronics/kicad/libraries.nix b/pkgs/applications/science/electronics/kicad/libraries.nix new file mode 100644 index 000000000000..9b262285e3c4 --- /dev/null +++ b/pkgs/applications/science/electronics/kicad/libraries.nix @@ -0,0 +1,50 @@ +{ stdenv, lib, fetchFromGitHub, cmake, gettext +, with3d ? true +}: + +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-libraries"; + version = "5.1.5"; + + passthru = { + symbols = mkLib "${version}" "symbols" "048b07ffsaav1ssrchw2p870lvb4rsyb5vnniy670k7q9p16qq6h" { + meta.license = licenses.cc-by-sa-40; + }; + templates = mkLib "${version}" "templates" "0cs3bm3zb5ngw5ldn0lzw5bvqm4kvcidyrn76438alffwiz2b15g" { + meta.license = licenses.cc-by-sa-40; + }; + footprints = mkLib "${version}" "footprints" "1c4whgn14qhz4yqkl46w13p6rpv1k0hsc9s9h9368fxfcz9knb2j" { + meta.license = licenses.cc-by-sa-40; + }; + i18n = mkLib "${version}" "i18n" "1rfpifl8vky1gba2angizlb2n7mwmsiai3r6ip6qma60wdj8sbd3" { + buildInputs = [ gettext ]; + meta.license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 + }; + packages3d = mkLib "${version}" "packages3d" "0cff2ms1bsw530kqb1fr1m2pjixyxzwa81mxgac3qpbcf8fnpvaz" { + hydraPlatforms = []; # this is a ~1 GiB download, occupies ~5 GiB in store + meta.license = licenses.cc-by-sa-40; + }; + }; + + meta = { + description = "Free Software EDA Suite, assets"; + homepage = "http://www.kicad-pcb.org/"; + license = with licenses; [ gpl2 cc-by-sa-40 ]; + maintainers = with maintainers; [ evils kiwi ]; + platforms = with platforms; linux; + }; + +} diff --git a/pkgs/applications/science/electronics/kicad/unstable.nix b/pkgs/applications/science/electronics/kicad/unstable.nix index f47faae972c4..70e6768bba43 100644 --- a/pkgs/applications/science/electronics/kicad/unstable.nix +++ b/pkgs/applications/science/electronics/kicad/unstable.nix @@ -4,8 +4,8 @@ , gsettings-desktop-schemas, librsvg, hicolor-icon-theme, cups , fetchpatch, kicad-libraries, lndir -, oceSupport ? true, opencascade -, withOCCT ? false, opencascade-occt +, oceSupport ? false, opencascade +, withOCCT ? true, opencascade-occt , ngspiceSupport ? true, libngspice , scriptingSupport ? true, swig, python, pythonPackages, wxPython , debug ? false, valgrind @@ -31,8 +31,8 @@ stdenv.mkDerivation rec { group = "kicad"; owner = "code"; repo = "kicad"; - rev = "65ef8c18944947c3305619032bd1aedbe8b99d64"; - sha256 = "0p0bm2yb34gqwks3qppwzgf5nylmn85psx2wwgk34yc8hs1p7yq0"; + rev = "ffcf3b01fce98f1bcbdf3b76fbc88228126be965"; + sha256 = "0qzjv06az1xl3am5v4v09nyfjcpq1wf3137wjv7a0vh8m38dvrwk"; }; patches = [ diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 4911f96fad62..c81964492442 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -192,6 +192,7 @@ mapAliases ({ keepassx-reboot = keepassx-community; # added 2017-02-01 keepassx2-http = keepassx-reboot; # added 2016-10-17 keybase-go = keybase; # added 2016-08-24 + kicad-with-packages3d = kicad; # added 2019-11-25 krename-qt5 = krename; # added 2017-02-18 keymon = throw "keymon has been removed from nixpkgs, as it's abandoned and archived."; # 2019-12-10 kvm = qemu_kvm; # added 2018-04-25 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fd46ca3af593..aa9dc70b5bda 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -24204,7 +24204,10 @@ in python = python3; wxPython = python3Packages.wxPython_4_0; }; - kicad-with-packages3d = kicad.overrideAttrs (old: { modules = old.modules ++ [ old.passthru.packages3d ]; }); + + kicad-small = kicad.override { with3d = false; }; + + kicad-libraries = callPackage ../applications/science/electronics/kicad/libraries.nix { }; kicad-unstable = callPackage ../applications/science/electronics/kicad/unstable.nix { # wxGTK31 currently introduces an issue with opening the python interpreter in pcbnew