2021-02-24 18:30:23 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-10-11 12:50:04 +00:00
|
|
|
, cmake
|
|
|
|
, libGLU
|
|
|
|
, libGL
|
|
|
|
, zlib
|
|
|
|
, wxGTK
|
|
|
|
, libX11
|
|
|
|
, gettext
|
|
|
|
, glew
|
|
|
|
, glm
|
|
|
|
, cairo
|
|
|
|
, curl
|
|
|
|
, openssl
|
|
|
|
, boost
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2020-10-11 12:50:04 +00:00
|
|
|
, doxygen
|
2021-05-20 23:08:51 +00:00
|
|
|
, graphviz
|
2020-10-11 12:50:04 +00:00
|
|
|
, pcre
|
|
|
|
, libpthreadstubs
|
|
|
|
, libXdmcp
|
|
|
|
, lndir
|
2020-10-16 20:44:37 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
, util-linux
|
|
|
|
, libselinux
|
|
|
|
, libsepol
|
|
|
|
, libthai
|
|
|
|
, libdatrie
|
|
|
|
, libxkbcommon
|
|
|
|
, epoxy
|
|
|
|
, dbus
|
|
|
|
, at-spi2-core
|
|
|
|
, libXtst
|
|
|
|
|
|
|
|
, swig
|
|
|
|
, python
|
|
|
|
, wxPython
|
|
|
|
, opencascade
|
|
|
|
, opencascade-occt
|
|
|
|
, libngspice
|
|
|
|
, valgrind
|
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
, stable
|
|
|
|
, baseName
|
|
|
|
, kicadSrc
|
|
|
|
, kicadVersion
|
|
|
|
, i18n
|
|
|
|
, withOCE
|
|
|
|
, withOCC
|
|
|
|
, withNgspice
|
|
|
|
, withScripting
|
|
|
|
, debug
|
2021-05-20 23:08:51 +00:00
|
|
|
, sanitizeAddress
|
|
|
|
, sanitizeThreads
|
2020-10-16 20:44:37 +00:00
|
|
|
, withI18n
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
assert lib.asserts.assertMsg (!(withOCE && stdenv.isAarch64)) "OCE fails a test on Aarch64";
|
|
|
|
assert lib.asserts.assertMsg (!(withOCC && withOCE))
|
2020-10-16 20:44:37 +00:00
|
|
|
"Only one of OCC and OCE may be enabled";
|
2021-05-20 23:08:51 +00:00
|
|
|
assert lib.assertMsg (!(stable && (sanitizeAddress || sanitizeThreads)))
|
|
|
|
"Only kicad-unstable(-small) supports address/thread sanitation";
|
|
|
|
assert lib.assertMsg (!(sanitizeAddress && sanitizeThreads))
|
|
|
|
"'sanitizeAddress' and 'sanitizeThreads' are mutually exclusive, use one.";
|
2021-07-14 22:03:04 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
2021-01-17 00:15:33 +00:00
|
|
|
inherit (lib) optional optionals;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2020-05-15 21:57:56 +00:00
|
|
|
pname = "kicad-base";
|
2021-05-20 23:08:51 +00:00
|
|
|
version = if (stable) then kicadVersion else builtins.substring 0 10 src.rev;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
src = kicadSrc;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# tagged releases don't have "unknown"
|
|
|
|
# kicad nightlies use git describe --dirty
|
|
|
|
# nix removes .git, so its approximated here
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace CMakeModules/KiCadVersion.cmake \
|
2021-05-20 23:08:51 +00:00
|
|
|
--replace "unknown" "${builtins.substring 0 10 src.rev}" \
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
makeFlags = optionals (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-14 22:03:04 +00:00
|
|
|
cmakeFlags = optionals (stable && withScripting) [
|
2021-05-20 23:08:51 +00:00
|
|
|
"-DKICAD_SCRIPTING=ON"
|
|
|
|
"-DKICAD_SCRIPTING_MODULES=ON"
|
|
|
|
"-DKICAD_SCRIPTING_PYTHON3=ON"
|
|
|
|
"-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON"
|
|
|
|
]
|
2021-07-14 22:03:04 +00:00
|
|
|
++ optionals (!withScripting) [
|
2021-05-20 23:08:51 +00:00
|
|
|
"-DKICAD_SCRIPTING=OFF"
|
2021-07-14 22:03:04 +00:00
|
|
|
"-DKICAD_SCRIPTING_WXPYTHON=OFF"
|
|
|
|
]
|
2021-05-20 23:08:51 +00:00
|
|
|
++ optional (withNgspice) "-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"
|
|
|
|
]
|
|
|
|
++ optionals (sanitizeAddress) [
|
|
|
|
"-DKICAD_SANITIZE_ADDRESS=ON"
|
|
|
|
]
|
|
|
|
++ optionals (sanitizeThreads) [
|
|
|
|
"-DKICAD_SANITIZE_THREADS=ON"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
doxygen
|
|
|
|
graphviz
|
|
|
|
pkg-config
|
|
|
|
lndir
|
|
|
|
]
|
|
|
|
# wanted by configuration on linux, doesn't seem to affect performance
|
|
|
|
# no effect on closure size
|
|
|
|
++ optionals (stdenv.isLinux) [
|
|
|
|
util-linux
|
|
|
|
libselinux
|
|
|
|
libsepol
|
|
|
|
libthai
|
|
|
|
libdatrie
|
|
|
|
libxkbcommon
|
|
|
|
epoxy
|
|
|
|
dbus.daemon
|
|
|
|
at-spi2-core
|
|
|
|
libXtst
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2020-10-11 12:50:04 +00:00
|
|
|
libGLU
|
|
|
|
libGL
|
|
|
|
zlib
|
|
|
|
libX11
|
|
|
|
wxGTK
|
2021-05-20 23:08:51 +00:00
|
|
|
wxGTK.gtk
|
2020-10-11 12:50:04 +00:00
|
|
|
pcre
|
|
|
|
libXdmcp
|
|
|
|
gettext
|
|
|
|
glew
|
|
|
|
glm
|
|
|
|
libpthreadstubs
|
|
|
|
cairo
|
|
|
|
curl
|
|
|
|
openssl
|
|
|
|
boost
|
2020-04-24 23:36:52 +00:00
|
|
|
]
|
2021-07-14 22:03:04 +00:00
|
|
|
# unstable requires swig and python
|
|
|
|
# wxPython still optional
|
|
|
|
++ optionals (withScripting || (!stable)) [ swig python ]
|
|
|
|
++ optional (withScripting) wxPython
|
2020-10-16 20:44:37 +00:00
|
|
|
++ optional (withNgspice) libngspice
|
2020-04-24 23:36:52 +00:00
|
|
|
++ 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
|
2020-05-15 21:57:56 +00:00
|
|
|
lndir ${i18n}/share $out/share
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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/";
|
2021-01-17 00:15:33 +00:00
|
|
|
license = lib.licenses.agpl3;
|
|
|
|
platforms = lib.platforms.all;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|