kicad: use separated libraries

switch source to gitlab as that's the new upstream source

use wrapper variables for everything but i18n
  add sym and fp templates to template path

update meta to reflect kicad's own language
  set license to AGPLv3, according to the source's LICENSE.README

reduce diff between default and unstable in preparation of merging

on debian gets "no module named 'math'"
  pcbnew 3d viewer is unusable (at least on my T410)
This commit is contained in:
Evils 2019-12-06 04:53:28 +01:00
parent c61170168d
commit 958d745fec
4 changed files with 62 additions and 98 deletions

View File

@ -1,8 +1,8 @@
{ lib, stdenv, fetchFromGitHub, cmake, libGLU, libGL, zlib, wxGTK { lib, stdenv, fetchFromGitLab, cmake, libGLU, libGL, zlib, wxGTK
, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig , libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig
, doxygen, pcre, libpthreadstubs, libXdmcp, makeWrapper, gnome3 , doxygen, pcre, libpthreadstubs, libXdmcp, makeWrapper, gnome3
, gsettings-desktop-schemas, librsvg, hicolor-icon-theme, lndir, cups , gsettings-desktop-schemas, librsvg, hicolor-icon-theme, cups
, fetchpatch , fetchpatch, kicad-libraries, lndir
, oceSupport ? false, opencascade , oceSupport ? false, opencascade
, withOCCT ? true, opencascade-occt , withOCCT ? true, opencascade-occt
@ -16,35 +16,24 @@ assert ngspiceSupport -> libngspice != null;
with lib; with lib;
let 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);
# oce on aarch64 fails a test # oce on aarch64 fails a test
withOCC = (stdenv.isAarch64 && (withOCCT || oceSupport)) || (!stdenv.isAarch64 && withOCCT); withOCC = (stdenv.isAarch64 && (withOCCT || oceSupport)) || (!stdenv.isAarch64 && withOCCT);
withOCE = oceSupport && !stdenv.isAarch64 && !withOCC; withOCE = oceSupport && !stdenv.isAarch64 && !withOCC;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "kicad"; pname = "kicad";
version = "5.1.5"; version = "5.1.5";
src = fetchFromGitHub { src = fetchFromGitLab {
owner = "KiCad"; group = "kicad";
repo = "kicad-source-mirror"; owner = "code";
repo = "kicad";
rev = version; rev = version;
sha256 = "15h3rwisjss3fdc9bam9n2wq94slhacc3fbg14bnzf4n5agsnv5b"; sha256 = "15h3rwisjss3fdc9bam9n2wq94slhacc3fbg14bnzf4n5agsnv5b";
}; };
# quick fix for #72248 # quick fix for #72248
# should be removed if a better fix is merged # should be removed if a a more permanent fix is published
patches = [ patches = [
(fetchpatch { (fetchpatch {
url = "https://github.com/johnbeard/kicad/commit/dfb1318a3989e3d6f9f2ac33c924ca5030ea273b.patch"; url = "https://github.com/johnbeard/kicad/commit/dfb1318a3989e3d6f9f2ac33c924ca5030ea273b.patch";
@ -52,11 +41,6 @@ stdenv.mkDerivation rec {
}) })
]; ];
postPatch = ''
substituteInPlace CMakeModules/KiCadVersion.cmake \
--replace "unknown" ${version}
'';
makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ]; makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ];
cmakeFlags = cmakeFlags =
@ -111,35 +95,9 @@ stdenv.mkDerivation rec {
dontStrip = debug; dontStrip = debug;
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;
};
};
# TODO, figure out how to skip this step? (since we're not making the 3D models optional)
modules = with passthru; [ i18n symbols footprints templates ]
++ optionals (with3d) [ packages3d ];
postInstall = '' postInstall = ''
mkdir -p $out/share mkdir -p $out/share
for module in $modules; do lndir ${kicad-libraries.i18n}/share $out/share
lndir $module/share $out/share
done
''; '';
makeWrapperArgs = [ makeWrapperArgs = [
@ -147,11 +105,19 @@ stdenv.mkDerivation rec {
"--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share" "--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share"
"--prefix XDG_DATA_DIRS : ${wxGTK.gtk}/share/gsettings-schemas/${wxGTK.gtk.name}" "--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}" "--prefix XDG_DATA_DIRS : ${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
# wrapGAppsHook did these, as well, no idea if it matters... # wrapGAppsHook did these two as well, no idea if it matters...
"--prefix XDG_DATA_DIRS : ${cups}/share" "--prefix XDG_DATA_DIRS : ${cups}/share"
"--prefix GIO_EXTRA_MODULES : ${gnome3.dconf}/lib/gio/modules" "--prefix GIO_EXTRA_MODULES : ${gnome3.dconf}/lib/gio/modules"
"--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 (ngspiceSupport) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ] ++ optionals (ngspiceSupport) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
++ optionals (with3d) [ "--set KISYS3DMOD ${kicad-libraries.packages3d}/share/kicad/modules/packages3d" ]
# infinisil's workaround for #39493 # infinisil's workaround for #39493
++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ] ++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]
; ;
@ -161,13 +127,13 @@ stdenv.mkDerivation rec {
preFixup = preFixup =
optionalString (scriptingSupport) '' buildPythonPath "$out $pythonPath" optionalString (scriptingSupport) '' buildPythonPath "$out $pythonPath"
'' + '' +
'' wrapProgram $out/bin/kicad $makeWrapperArgs --prefix XDG_DATA_DIRS : $out/share --set KICAD_SYMBOL_DIR $out/share/kicad/library --set KICAD_TEMPLATE_DIR $out/share/kicad/template --set KISYS3DMOD $out/share/kicad/modules/packages3d --set KISYSMOD $out/share/kicad/modules '' '' wrapProgram $out/bin/kicad $makeWrapperArgs --prefix XDG_DATA_DIRS : $out/share ''
+ optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
'' + '' +
'' wrapProgram $out/bin/pcbnew $makeWrapperArgs --prefix XDG_DATA_DIRS : $out/share --set KISYS3DMOD $out/share/kicad/modules/packages3d '' '' wrapProgram $out/bin/pcbnew $makeWrapperArgs --prefix XDG_DATA_DIRS : $out/share ''
+ optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
'' + '' +
'' wrapProgram $out/bin/eeschema $makeWrapperArgs --prefix XDG_DATA_DIRS : $out/share --set KICAD_SYMBOL_DIR $out/share/kicad/library '' '' wrapProgram $out/bin/eeschema $makeWrapperArgs --prefix XDG_DATA_DIRS : $out/share ''
+ optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
'' + '' +
'' wrapProgram $out/bin/gerbview $makeWrapperArgs --prefix XDG_DATA_DIRS : $out/share '' '' wrapProgram $out/bin/gerbview $makeWrapperArgs --prefix XDG_DATA_DIRS : $out/share ''
@ -185,9 +151,13 @@ stdenv.mkDerivation rec {
; ;
meta = { meta = {
description = "Free Software EDA Suite"; description = "Open Source Electronics Design Automation Suite";
homepage = "http://www.kicad-pcb.org/"; homepage = "https://www.kicad-pcb.org/";
license = with licenses; [ gpl2 cc-by-sa-40 ]; 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;
maintainers = with maintainers; [ evils kiwi berce ]; maintainers = with maintainers; [ evils kiwi berce ];
platforms = with platforms; linux; platforms = with platforms; linux;
}; };

View File

@ -4,6 +4,7 @@
with lib; with lib;
let let
version = "5.1.5";
mkLib = version: name: sha256: attrs: stdenv.mkDerivation ({ mkLib = version: name: sha256: attrs: stdenv.mkDerivation ({
name = "kicad-${name}-${version}"; name = "kicad-${name}-${version}";
src = fetchFromGitHub { src = fetchFromGitHub {
@ -15,36 +16,22 @@ let
nativeBuildInputs = [ cmake ]; nativeBuildInputs = [ cmake ];
} // attrs); } // attrs);
in in
stdenv.mkDerivation rec { {
pname = "kicad-libraries"; symbols = mkLib "${version}" "symbols" "048b07ffsaav1ssrchw2p870lvb4rsyb5vnniy670k7q9p16qq6h" {
version = "5.1.5"; meta.license = licenses.cc-by-sa-40;
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;
};
}; };
templates = mkLib "${version}" "templates" "0cs3bm3zb5ngw5ldn0lzw5bvqm4kvcidyrn76438alffwiz2b15g" {
meta = { meta.license = licenses.cc-by-sa-40;
description = "Free Software EDA Suite, assets"; };
homepage = "http://www.kicad-pcb.org/"; footprints = mkLib "${version}" "footprints" "1c4whgn14qhz4yqkl46w13p6rpv1k0hsc9s9h9368fxfcz9knb2j" {
license = with licenses; [ gpl2 cc-by-sa-40 ]; meta.license = licenses.cc-by-sa-40;
maintainers = with maintainers; [ evils kiwi ]; };
platforms = with platforms; linux; 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;
}; };
} }

View File

@ -12,20 +12,18 @@
, with3d ? true , with3d ? true
}: }:
assert ngspiceSupport -> libngspice != null; assert ngspiceSupport -> libngspice != null;
with lib; with lib;
# oce on aarch64 fails a test
let let
# oce on aarch64 fails a test
withOCC = (stdenv.isAarch64 && (withOCCT || oceSupport)) || (!stdenv.isAarch64 && withOCCT); withOCC = (stdenv.isAarch64 && (withOCCT || oceSupport)) || (!stdenv.isAarch64 && withOCCT);
withOCE = oceSupport && !stdenv.isAarch64 && !withOCC; withOCE = oceSupport && !stdenv.isAarch64 && !withOCC;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "kicad-unstable"; pname = "kicad-unstable";
version = "2019-12-05"; version = "2019-12-10";
src = fetchFromGitLab { src = fetchFromGitLab {
group = "kicad"; group = "kicad";
@ -35,6 +33,8 @@ stdenv.mkDerivation rec {
sha256 = "0qzjv06az1xl3am5v4v09nyfjcpq1wf3137wjv7a0vh8m38dvrwk"; sha256 = "0qzjv06az1xl3am5v4v09nyfjcpq1wf3137wjv7a0vh8m38dvrwk";
}; };
# quick fix for #72248
# should be removed if a a more permanent fix is published
patches = [ patches = [
(fetchpatch { (fetchpatch {
url = "https://github.com/johnbeard/kicad/commit/dfb1318a3989e3d6f9f2ac33c924ca5030ea273b.patch"; url = "https://github.com/johnbeard/kicad/commit/dfb1318a3989e3d6f9f2ac33c924ca5030ea273b.patch";
@ -42,6 +42,7 @@ stdenv.mkDerivation rec {
}) })
]; ];
# tagged releases don't have "unknown"
postPatch = '' postPatch = ''
substituteInPlace CMakeModules/KiCadVersion.cmake \ substituteInPlace CMakeModules/KiCadVersion.cmake \
--replace "unknown" ${version} --replace "unknown" ${version}
@ -61,8 +62,10 @@ stdenv.mkDerivation rec {
++ optional (ngspiceSupport) "-DKICAD_SPICE=ON" ++ optional (ngspiceSupport) "-DKICAD_SPICE=ON"
++ optionals (withOCE) ++ optionals (withOCE)
[ "-DKICAD_USE_OCE=ON" "-DOCE_DIR=${opencascade}" ] [ "-DKICAD_USE_OCE=ON" "-DOCE_DIR=${opencascade}" ]
++ optionals (withOCC) ++ optionals (withOCC) [
[ "-DKICAD_USE_OCC=ON" "-DOCC_INCLUDE_DIR=${opencascade-occt}/include/opencascade" ] "-DKICAD_USE_OCC=ON"
"-DOCC_INCLUDE_DIR=${opencascade-occt}/include/opencascade"
]
++ optionals (debug) [ ++ optionals (debug) [
"-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_BUILD_TYPE=Debug"
"-DKICAD_STDLIB_DEBUG=ON" "-DKICAD_STDLIB_DEBUG=ON"
@ -106,7 +109,7 @@ stdenv.mkDerivation rec {
"--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share" "--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share"
"--prefix XDG_DATA_DIRS : ${wxGTK.gtk}/share/gsettings-schemas/${wxGTK.gtk.name}" "--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}" "--prefix XDG_DATA_DIRS : ${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
# wrapGAppsHook did these, as well, no idea if it matters... # wrapGAppsHook did these two as well, no idea if it matters...
"--prefix XDG_DATA_DIRS : ${cups}/share" "--prefix XDG_DATA_DIRS : ${cups}/share"
"--prefix GIO_EXTRA_MODULES : ${gnome3.dconf}/lib/gio/modules" "--prefix GIO_EXTRA_MODULES : ${gnome3.dconf}/lib/gio/modules"
@ -152,9 +155,13 @@ stdenv.mkDerivation rec {
; ;
meta = { meta = {
description = "Free Software EDA Suite, Nightly Development Build"; description = "Open Source EDA Suite, Development Build";
homepage = "https://www.kicad-pcb.org/"; homepage = "https://www.kicad-pcb.org/";
license = licenses.gpl2; 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;
maintainers = with maintainers; [ evils kiwi berce ]; maintainers = with maintainers; [ evils kiwi berce ];
platforms = with platforms; linux; platforms = with platforms; linux;
}; };

View File

@ -24207,7 +24207,7 @@ in
kicad-small = kicad.override { with3d = false; }; kicad-small = kicad.override { with3d = false; };
kicad-libraries = callPackage ../applications/science/electronics/kicad/libraries.nix { }; kicad-libraries = callPackages ../applications/science/electronics/kicad/libraries.nix { };
kicad-unstable = callPackage ../applications/science/electronics/kicad/unstable.nix { kicad-unstable = callPackage ../applications/science/electronics/kicad/unstable.nix {
# wxGTK31 currently introduces an issue with opening the python interpreter in pcbnew # wxGTK31 currently introduces an issue with opening the python interpreter in pcbnew