Merge pull request #82634 from evils/kicad

This commit is contained in:
Jörg Thalheim 2020-05-11 10:27:18 +01:00 committed by GitHub
commit 3a9543b778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 106 additions and 89 deletions

View File

@ -2,7 +2,6 @@
, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig , libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig
, doxygen, pcre, libpthreadstubs, libXdmcp, fetchpatch, lndir, callPackages , doxygen, pcre, libpthreadstubs, libXdmcp, fetchpatch, lndir, callPackages
, pname ? "kicad"
, stable ? true , stable ? true
, baseName ? "kicad" , baseName ? "kicad"
, versions ? { } , versions ? { }
@ -20,26 +19,26 @@ with lib;
let let
versionConfig = versions.${baseName}; versionConfig = versions.${baseName};
baseVersion = "${versions.${baseName}.kicadVersion.version}";
# oce on aarch64 fails a test # oce on aarch64 fails a test
withOCE = oceSupport && !stdenv.isAarch64; withOCE = oceSupport && !stdenv.isAarch64;
withOCC = (withOCCT && !withOCE) || (oceSupport && stdenv.isAarch64); withOCC = (withOCCT && !withOCE) || (oceSupport && stdenv.isAarch64);
kicad-libraries = callPackages ./libraries.nix versionConfig.libVersion; libraries = callPackages ./libraries.nix versionConfig.libVersion;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
inherit pname; i18n = libraries.i18n;
version = "base-${baseVersion}";
pname = "kicad-base";
version = "${versions.${baseName}.kicadVersion.version}";
src = fetchFromGitLab ( src = fetchFromGitLab (
{ {
group = "kicad"; group = "kicad";
owner = "code"; owner = "code";
repo = "kicad"; repo = "kicad";
rev = baseVersion;
} // versionConfig.kicadVersion.src } // versionConfig.kicadVersion.src
); );
@ -57,9 +56,11 @@ stdenv.mkDerivation rec {
# tagged releases don't have "unknown" # tagged releases don't have "unknown"
# kicad nightlies use git describe --dirty # kicad nightlies use git describe --dirty
# nix removes .git, so its approximated here # nix removes .git, so its approximated here
# "-1" appended to indicate we're adding a patch
postPatch = '' postPatch = ''
substituteInPlace CMakeModules/KiCadVersion.cmake \ substituteInPlace CMakeModules/KiCadVersion.cmake \
--replace "unknown" ${builtins.substring 0 10 src.rev} --replace "unknown" "${builtins.substring 0 10 src.rev}-1" \
--replace "${version}" "${version}-1"
''; '';
makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ]; makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ];
@ -113,7 +114,7 @@ stdenv.mkDerivation rec {
postInstall = optional (withI18n) '' postInstall = optional (withI18n) ''
mkdir -p $out/share mkdir -p $out/share
lndir ${kicad-libraries.i18n}/share $out/share lndir ${i18n}/share $out/share
''; '';
meta = { meta = {
@ -124,7 +125,6 @@ stdenv.mkDerivation rec {
''; '';
homepage = "https://www.kicad-pcb.org/"; homepage = "https://www.kicad-pcb.org/";
license = licenses.agpl3; license = licenses.agpl3;
maintainers = with maintainers; [ evils kiwi berce ]; platforms = platforms.all;
platforms = with platforms; linux;
}; };
} }

View File

@ -4,6 +4,7 @@
, librsvg, cups , librsvg, cups
, pname ? "kicad" , pname ? "kicad"
, stable ? true
, oceSupport ? false, opencascade , oceSupport ? false, opencascade
, withOCCT ? true, opencascade-occt , withOCCT ? true, opencascade-occt
, ngspiceSupport ? true, libngspice , ngspiceSupport ? true, libngspice
@ -18,7 +19,6 @@ assert ngspiceSupport -> libngspice != null;
with lib; with lib;
let let
stable = pname != "kicad-unstable";
baseName = if (stable) then "kicad" else "kicad-unstable"; baseName = if (stable) then "kicad" else "kicad-unstable";
versions = import ./versions.nix; versions = import ./versions.nix;
@ -35,17 +35,16 @@ let
python = python3; python = python3;
wxPython = python3Packages.wxPython_4_0; 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 { base = callPackage ./base.nix {
pname = baseName;
inherit versions stable baseName; inherit versions stable baseName;
inherit wxGTK python wxPython; inherit wxGTK python wxPython;
inherit debug withI18n withOCCT oceSupport ngspiceSupport scriptingSupport; inherit debug withI18n withOCCT oceSupport ngspiceSupport scriptingSupport;
}; };
in
stdenv.mkDerivation rec {
inherit pname; inherit pname;
version = versions.${baseName}.kicadVersion.version; version = versions.${baseName}.kicadVersion.version;
@ -63,7 +62,7 @@ stdenv.mkDerivation rec {
# wrapGAppsHook added the equivalent to ${base}/share # wrapGAppsHook added the equivalent to ${base}/share
# though i noticed no difference without it # though i noticed no difference without it
makeWrapperArgs = [ makeWrapperArgs = with passthru.libraries; [
"--prefix XDG_DATA_DIRS : ${base}/share" "--prefix XDG_DATA_DIRS : ${base}/share"
"--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share" "--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share"
"--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share" "--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share"
@ -73,47 +72,40 @@ stdenv.mkDerivation rec {
"--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 ${libraries.footprints}/share/kicad/modules" "--set KISYSMOD ${footprints}/share/kicad/modules"
"--set KICAD_SYMBOL_DIR ${libraries.symbols}/share/kicad/library" "--set KICAD_SYMBOL_DIR ${symbols}/share/kicad/library"
"--set KICAD_TEMPLATE_DIR ${libraries.templates}/share/kicad/template" "--set KICAD_TEMPLATE_DIR ${templates}/share/kicad/template"
"--prefix KICAD_TEMPLATE_DIR : ${libraries.symbols}/share/kicad/template" "--prefix KICAD_TEMPLATE_DIR : ${symbols}/share/kicad/template"
"--prefix KICAD_TEMPLATE_DIR : ${libraries.footprints}/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" ] ++ optionals (ngspiceSupport) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
# 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" ]
; ;
# 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? # $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 # kicad-ogltest's source seems to indicate that crashing is expected behaviour...
# dxf2idf, idf2vrml, idfcyl, idfrect, kicad2step, kicad-ogltest installPhase = with lib;
installPhase = let
optionalString (scriptingSupport) '' buildPythonPath "${base} $pythonPath" tools = [ "kicad" "pcbnew" "eeschema" "gerbview" "pcb_calculator" "pl_editor" "bitmap2component" ];
'' + utils = [ "dxf2idf" "idf2vrml" "idfcyl" "idfrect" "kicad2step" "kicad-ogltest" ];
'' makeWrapper ${base}/bin/kicad $out/bin/kicad $makeWrapperArgs '' in
+ optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" ( concatStringsSep "\n"
'' + ( flatten [
'' makeWrapper ${base}/bin/pcbnew $out/bin/pcbnew $makeWrapperArgs '' ( optionalString (scriptingSupport) "buildPythonPath \"${base} $pythonPath\" \n" )
+ optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH"
'' + # wrap each of the directly usable tools
'' makeWrapper ${base}/bin/eeschema $out/bin/eeschema $makeWrapperArgs '' ( map ( tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs"
+ optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" + optionalString (scriptingSupport) " --set PYTHONPATH \"$program_PYTHONPATH\""
'' + ) tools )
'' makeWrapper ${base}/bin/gerbview $out/bin/gerbview $makeWrapperArgs ''
+ optionalString (scriptingSupport) '' --set PYTHONPATH "$program_PYTHONPATH" # link in the CLI utils
'' + ( map ( util: "ln -s ${base}/bin/${util} $out/bin/${util}" ) utils )
'' 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"
''
; ;
# can't run this for each pname # 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 # and can't git commit if this could be running in parallel with other scripts
passthru.updateScript = [ ./update.sh "all" ]; passthru.updateScript = [ ./update.sh "all" ];
meta = { meta = rec {
description = if (stable) description = (if (stable)
then "Open Source Electronics Design Automation Suite" then "Open Source Electronics Design Automation suite"
else "Open Source EDA Suite, Development Build"; else "Open Source EDA suite, development build")
+ (if (!with3d) then ", without 3D models" else "");
homepage = "https://www.kicad-pcb.org/"; homepage = "https://www.kicad-pcb.org/";
longDescription = '' longDescription = ''
KiCad is an open source software suite for Electronic Design Automation. KiCad is an open source software suite for Electronic Design Automation.
@ -134,12 +127,20 @@ stdenv.mkDerivation rec {
''; '';
license = licenses.agpl3; license = licenses.agpl3;
# berce seems inactive... # berce seems inactive...
maintainers = with maintainers; [ evils kiwi berce ]; maintainers = with stdenv.lib.maintainers; [ evils kiwi berce ];
# kicad's cross-platform, not sure what to fill in here # kicad is cross platform
platforms = with platforms; linux; platforms = stdenv.lib.platforms.all;
} // optionalAttrs with3d { # despite that, nipkgs' wxGTK for darwin is "wxmac"
# We can't download the 3d models on Hydra - they are a ~1 GiB download and # and wxPython_4_0 does not account for this
# they occupy ~5 GiB in store. # adjusting this package to downgrade to python2Packages.wxPython (wxPython 3),
hydraPlatforms = []; # 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
}; };
} }

View File

@ -13,21 +13,27 @@
with lib; with lib;
let let
mkLib = name: mkLib = name:
stdenv.mkDerivation stdenv.mkDerivation {
{ pname = "kicad-${name}";
pname = "kicad-${name}"; version = "${version}";
version = "${version}"; src = fetchFromGitHub (
src = fetchFromGitHub ( {
{ owner = "KiCad";
owner = "KiCad"; repo = "kicad-${name}";
repo = "kicad-${name}"; rev = version;
rev = version; inherit name;
inherit name; } // (libSources.${name} or { })
} // (libSources.${name} or { }) );
); nativeBuildInputs = [ cmake ];
nativeBuildInputs = [ cmake ];
meta.license = licenses.cc-by-sa-40; meta = rec {
license = licenses.cc-by-sa-40;
platforms = stdenv.lib.platforms.all;
# the 3d models are a ~1 GiB download and occupy ~5 GiB in store.
# this would exceed the hydra output limit
hydraPlatforms = if (name == "packages3d" ) then [ ] else platforms;
}; };
};
in in
{ {
symbols = mkLib "symbols"; symbols = mkLib "symbols";
@ -56,6 +62,9 @@ in
); );
buildInputs = [ gettext ]; buildInputs = [ gettext ];
nativeBuildInputs = [ cmake ]; nativeBuildInputs = [ cmake ];
meta.license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 meta = {
license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3
platforms = stdenv.lib.platforms.all;
};
}; };
} }

View File

@ -27,25 +27,25 @@
}; };
"kicad-unstable" = { "kicad-unstable" = {
kicadVersion = { kicadVersion = {
version = "2020-04-25"; version = "2020-05-06";
src = { src = {
rev = "3759799d1e03b2da6a0dcd72273e4978880fc8f1"; rev = "c92181621e2e51dc8aae1bd9f4483bb3301ffaa5";
sha256 = "0ba14fla8m5zli68wfjkfc4ymvj4j8z92y3jigxs8hys0450bybi"; sha256 = "0s50xn5gbjy7yxnp9yiynxvxi2mkcrp6yghgdzclpm40rnfyi0v5";
}; };
}; };
libVersion = { libVersion = {
version = "2020-04-25"; version = "2020-05-06";
libSources = { libSources = {
i18n.rev = "fc14baa52ca56a58b0048ab860bf31887d3cf8eb"; i18n.rev = "f29cab831eb823165fa2c5efab5d9c9b443e62e2";
i18n.sha256 = "05nayab7dkjyq7g3i9q7k55hcckpc0cmq4bbklmxx16rx4rbhzc6"; i18n.sha256 = "0cc0zvpml75yxphay3281f762ls08fzvv538cd5hmkr8xqlj3vbi";
symbols.rev = "0f9ff2d17237f90bb649bf0a52b6d454f68197e8"; symbols.rev = "d4245ae8cf633095a0994ab01492bd56cd124112";
symbols.sha256 = "1a54428syn2xksc00n2bvh1alrx2vrqmp7cg7d2rn8nlq8yk4qd5"; symbols.sha256 = "11pynjgji3skw42q5mryz98f8z418k43jy6s2k90w6jv638z3cb0";
templates.rev = "7db8d4d0ea0711f1961d117853547fb3edbc3857"; templates.rev = "7db8d4d0ea0711f1961d117853547fb3edbc3857";
templates.sha256 = "1hppcsrkn4dk6ggby6ckh0q65qxkywrbyxa4lwpaf7pxjyv498xg"; templates.sha256 = "1hppcsrkn4dk6ggby6ckh0q65qxkywrbyxa4lwpaf7pxjyv498xg";
footprints.rev = "61df6d8853b4c68cca0ac87784c0a33cff9394d3"; footprints.rev = "3bff23ee339bc48490bb39deba5d8b2f1f42733e";
footprints.sha256 = "0blmhk8pwd4mi6rlsr4lf4lq7j01h6xbpbvr3pm8pmw8zylhi54v"; footprints.sha256 = "0430r8k49ib6w1sjr8fx42szbz960yhlzg4w80jl5bwasq67nqwd";
packages3d.rev = "88bcf2e817fe000bb2c05e14489afc3b1a4e10ed"; packages3d.rev = "889a3dd550233ec51baed4a04a01d4cc64a8d747";
packages3d.sha256 = "0z9p1fn5xbz940kr5jz2ibzf09hpdi1c9izmabkffvrnfy6408x6"; packages3d.sha256 = "152zv4j51v8skqlvrabblpcqpbn5yf3grisjj8vnwf7kdd41chb2";
}; };
}; };
}; };

View File

@ -24956,9 +24956,16 @@ in
fped = callPackage ../applications/science/electronics/fped { }; fped = callPackage ../applications/science/electronics/fped { };
# this is a wrapper for kicad.base and kicad.libraries
kicad = callPackage ../applications/science/electronics/kicad { }; kicad = callPackage ../applications/science/electronics/kicad { };
kicad-small = kicad.override { pname = "kicad-small"; with3d = false; }; kicad-small = kicad.override { pname = "kicad-small"; with3d = false; };
kicad-unstable = kicad.override { pname = "kicad-unstable"; debug = true; }; kicad-unstable = kicad.override { pname = "kicad-unstable"; stable = false; };
# mostly here so the kicad-unstable components (except packages3d) get built
kicad-unstable-small = kicad.override {
pname = "kicad-unstable-small";
stable = false;
with3d = false;
};
librepcb = libsForQt5.callPackage ../applications/science/electronics/librepcb { }; librepcb = libsForQt5.callPackage ../applications/science/electronics/librepcb { };