2021-01-15 13:21:58 +00:00
|
|
|
{ lib, stdenv
|
2020-10-10 23:37:15 +01:00
|
|
|
, fetchFromGitLab
|
2021-05-07 22:18:14 +01:00
|
|
|
, gnome
|
2021-03-16 17:42:35 +00:00
|
|
|
, dconf
|
2020-10-10 20:50:41 +01:00
|
|
|
, wxGTK30
|
|
|
|
, wxGTK31
|
2020-07-21 07:52:04 +01:00
|
|
|
, makeWrapper
|
2020-10-10 20:50:41 +01:00
|
|
|
, gsettings-desktop-schemas
|
|
|
|
, hicolor-icon-theme
|
|
|
|
, callPackage
|
|
|
|
, callPackages
|
|
|
|
, librsvg
|
|
|
|
, cups
|
2019-11-05 03:15:14 +00:00
|
|
|
|
2019-12-14 16:01:15 +00:00
|
|
|
, pname ? "kicad"
|
2020-03-28 00:39:57 +00:00
|
|
|
, stable ? true
|
2020-10-10 20:50:41 +01:00
|
|
|
, oceSupport ? false
|
2020-10-10 22:44:56 +01:00
|
|
|
, withOCE ? false
|
|
|
|
, withOCCT ? false
|
|
|
|
, withOCC ? true
|
|
|
|
, ngspiceSupport ? false
|
|
|
|
, withNgspice ? true
|
2020-10-10 20:50:41 +01:00
|
|
|
, libngspice
|
2020-10-10 22:44:56 +01:00
|
|
|
, scriptingSupport ? false
|
|
|
|
, withScripting ? true
|
2020-10-10 20:50:41 +01:00
|
|
|
, python3
|
|
|
|
, debug ? false
|
2021-01-23 09:58:33 +00:00
|
|
|
, sanitizeAddress ? false
|
|
|
|
, sanitizeThreads ? false
|
2019-11-05 03:15:14 +00:00
|
|
|
, with3d ? true
|
2019-12-15 03:30:15 +00:00
|
|
|
, withI18n ? true
|
2020-10-11 00:10:53 +01:00
|
|
|
, srcs ? { }
|
2018-07-26 13:47:07 +01:00
|
|
|
}:
|
2010-08-31 09:19:28 +01:00
|
|
|
|
2020-10-11 00:10:53 +01:00
|
|
|
# The `srcs` parameter can be used to override the kicad source code
|
|
|
|
# and all libraries (including i18n), which are otherwise inaccessible
|
|
|
|
# to overlays since most of the kicad build expression has been
|
|
|
|
# refactored into base.nix, most of the library build expressions have
|
|
|
|
# been refactored into libraries.nix, and most the i18n build
|
|
|
|
# expression has been refactored into i18n.nix. Overrides are only
|
|
|
|
# applied when building `kicad-unstable`. The `srcs` parameter has no
|
|
|
|
# effect for stable `kicad`. `srcs` takes an attribute set in which
|
|
|
|
# any of the following attributes are meaningful (though none are
|
|
|
|
# mandatory): "kicad", "kicadVersion", "i18n", "symbols", "templates",
|
|
|
|
# "footprints", "packages3d", and "libVersion". "kicadVersion" and
|
|
|
|
# "libVersion" should be set to a string with the desired value for
|
|
|
|
# the version attribute in kicad's `mkDerivation` and the version
|
|
|
|
# attribute in any of the library's or i18n's `mkDerivation`,
|
|
|
|
# respectively. "kicad", "i18n", "symbols", "templates", "footprints",
|
|
|
|
# and "packages3d" should be set to an appropriate fetcher (e.g.,
|
|
|
|
# `fetchFromGitLab`). So, for example, a possible overlay for kicad
|
|
|
|
# is:
|
|
|
|
#
|
|
|
|
# final: prev:
|
|
|
|
|
|
|
|
# {
|
|
|
|
# kicad-unstable = (prev.kicad-unstable.override {
|
|
|
|
# srcs = {
|
|
|
|
# kicadVersion = "2020-10-08";
|
|
|
|
# kicad = prev.fetchFromGitLab {
|
|
|
|
# group = "kicad";
|
|
|
|
# owner = "code";
|
|
|
|
# repo = "kicad";
|
|
|
|
# rev = "fd22fe8e374ce71d57e9f683ba996651aa69fa4e";
|
|
|
|
# sha256 = "sha256-F8qugru/jU3DgZSpQXQhRGNFSk0ybFRkpyWb7HAGBdc=";
|
|
|
|
# };
|
|
|
|
# };
|
|
|
|
# });
|
|
|
|
# }
|
|
|
|
|
2020-10-10 22:44:56 +01:00
|
|
|
assert withNgspice -> libngspice != null;
|
2021-01-15 13:21:58 +00:00
|
|
|
assert lib.assertMsg (!ngspiceSupport)
|
2020-10-10 22:44:56 +01:00
|
|
|
"`nspiceSupport` was renamed to `withNgspice` for the sake of consistency with other kicad nix arguments.";
|
2021-01-15 13:21:58 +00:00
|
|
|
assert lib.assertMsg (!oceSupport)
|
2020-10-10 22:44:56 +01:00
|
|
|
"`oceSupport` was renamed to `withOCE` for the sake of consistency with other kicad nix arguments.";
|
2021-01-15 13:21:58 +00:00
|
|
|
assert lib.assertMsg (!scriptingSupport)
|
2020-10-10 22:44:56 +01:00
|
|
|
"`scriptingSupport` was renamed to `withScripting` for the sake of consistency with other kicad nix arguments.";
|
2021-01-15 13:21:58 +00:00
|
|
|
assert lib.assertMsg (!withOCCT)
|
2020-10-10 22:44:56 +01:00
|
|
|
"`withOCCT` was renamed to `withOCC` for the sake of consistency with upstream cmake options.";
|
2019-03-11 15:54:13 +00:00
|
|
|
let
|
2019-12-15 11:26:23 +00:00
|
|
|
baseName = if (stable) then "kicad" else "kicad-unstable";
|
2020-10-11 00:10:53 +01:00
|
|
|
versionsImport = import ./versions.nix;
|
|
|
|
|
|
|
|
# versions.nix does not provide us with version, src and rev. We
|
|
|
|
# need to turn this into approprate fetcher calls.
|
|
|
|
kicadSrcFetch = fetchFromGitLab {
|
|
|
|
group = "kicad";
|
|
|
|
owner = "code";
|
|
|
|
repo = "kicad";
|
|
|
|
rev = versionsImport.${baseName}.kicadVersion.src.rev;
|
|
|
|
sha256 = versionsImport.${baseName}.kicadVersion.src.sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
i18nSrcFetch = fetchFromGitLab {
|
|
|
|
group = "kicad";
|
|
|
|
owner = "code";
|
|
|
|
repo = "kicad-i18n";
|
|
|
|
rev = versionsImport.${baseName}.libVersion.libSources.i18n.rev;
|
|
|
|
sha256 = versionsImport.${baseName}.libVersion.libSources.i18n.sha256;
|
|
|
|
};
|
2019-12-15 03:30:15 +00:00
|
|
|
|
2020-10-11 00:10:53 +01:00
|
|
|
libSrcFetch = name: fetchFromGitLab {
|
|
|
|
group = "kicad";
|
|
|
|
owner = "libraries";
|
|
|
|
repo = "kicad-${name}";
|
|
|
|
rev = versionsImport.${baseName}.libVersion.libSources.${name}.rev;
|
|
|
|
sha256 = versionsImport.${baseName}.libVersion.libSources.${name}.sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
# only override `src` or `version` if building `kicad-unstable` with
|
|
|
|
# the appropriate attribute defined in `srcs`.
|
|
|
|
srcOverridep = attr: (!stable && builtins.hasAttr attr srcs);
|
|
|
|
|
|
|
|
# use default source and version (as defined in versions.nix) by
|
|
|
|
# default, or use the appropriate attribute from `srcs` if building
|
|
|
|
# unstable with `srcs` properly defined.
|
|
|
|
kicadSrc =
|
|
|
|
if srcOverridep "kicad" then srcs.kicad
|
|
|
|
else kicadSrcFetch;
|
|
|
|
kicadVersion =
|
|
|
|
if srcOverridep "kicadVersion" then srcs.kicadVersion
|
|
|
|
else versionsImport.${baseName}.kicadVersion.version;
|
|
|
|
|
|
|
|
i18nSrc = if srcOverridep "i18n" then srcs.i18n else i18nSrcFetch;
|
|
|
|
i18nVersion =
|
|
|
|
if srcOverridep "i18nVersion" then srcs.i18nVersion
|
|
|
|
else versionsImport.${baseName}.libVersion.version;
|
|
|
|
|
|
|
|
libSrc = name: if srcOverridep name then srcs.${name} else libSrcFetch name;
|
|
|
|
# TODO does it make sense to only have one version for all libs?
|
|
|
|
libVersion =
|
|
|
|
if srcOverridep "libVersion" then srcs.libVersion
|
|
|
|
else versionsImport.${baseName}.libVersion.version;
|
2019-12-15 03:30:15 +00:00
|
|
|
|
2020-10-10 20:50:41 +01:00
|
|
|
wxGTK =
|
|
|
|
if (stable)
|
2019-12-15 03:30:15 +00:00
|
|
|
# wxGTK3x may default to withGtk2 = false, see #73145
|
2020-10-10 20:50:41 +01:00
|
|
|
then
|
|
|
|
wxGTK30.override
|
|
|
|
{
|
|
|
|
withGtk2 = false;
|
|
|
|
}
|
2019-12-15 03:30:15 +00:00
|
|
|
# wxGTK31 currently introduces an issue with opening the python interpreter in pcbnew
|
|
|
|
# but brings high DPI support?
|
2020-10-10 20:50:41 +01:00
|
|
|
else
|
|
|
|
wxGTK31.override {
|
|
|
|
withGtk2 = false;
|
|
|
|
};
|
2019-12-15 03:30:15 +00:00
|
|
|
|
|
|
|
python = python3;
|
2021-01-18 01:22:16 +00:00
|
|
|
wxPython = if (stable)
|
|
|
|
then python.pkgs.wxPython_4_0
|
|
|
|
else python.pkgs.wxPython_4_1;
|
2019-12-14 16:01:15 +00:00
|
|
|
|
2021-01-15 13:21:58 +00:00
|
|
|
inherit (lib) concatStringsSep flatten optionalString optionals;
|
2020-03-30 05:13:59 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
2020-10-11 00:10:53 +01:00
|
|
|
# Common libraries, referenced during runtime, via the wrapper.
|
2021-04-07 06:39:58 +01:00
|
|
|
passthru.libraries = callPackages ./libraries.nix { inherit libSrc; };
|
|
|
|
passthru.i18n = callPackage ./i18n.nix { src = i18nSrc; };
|
2020-01-12 15:45:35 +00:00
|
|
|
base = callPackage ./base.nix {
|
2020-10-11 00:10:53 +01:00
|
|
|
inherit stable baseName;
|
|
|
|
inherit kicadSrc kicadVersion;
|
|
|
|
inherit (passthru) i18n;
|
2019-12-15 11:26:23 +00:00
|
|
|
inherit wxGTK python wxPython;
|
2021-01-23 09:58:33 +00:00
|
|
|
inherit withI18n withOCC withOCE withNgspice withScripting;
|
|
|
|
inherit debug sanitizeAddress sanitizeThreads;
|
2019-12-15 03:30:15 +00:00
|
|
|
};
|
|
|
|
|
2019-12-14 16:01:15 +00:00
|
|
|
inherit pname;
|
2021-04-07 06:39:58 +01:00
|
|
|
version = if (stable) then kicadVersion else builtins.substring 0 10 src.src.rev;
|
2019-11-05 03:15:14 +00:00
|
|
|
|
2020-01-12 15:45:35 +00:00
|
|
|
src = base;
|
2019-12-15 11:26:23 +00:00
|
|
|
dontUnpack = true;
|
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
|
|
|
dontFixup = true;
|
2018-07-31 14:37:59 +01:00
|
|
|
|
2020-10-10 22:44:56 +01:00
|
|
|
pythonPath = optionals (withScripting)
|
2020-07-21 07:52:04 +01:00
|
|
|
[ wxPython python.pkgs.six ];
|
2018-07-31 14:37:59 +01:00
|
|
|
|
2020-07-21 07:52:04 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ]
|
2020-10-10 22:44:56 +01:00
|
|
|
++ optionals (withScripting)
|
2020-10-10 20:50:41 +01:00
|
|
|
[ python.pkgs.wrapPython ];
|
2019-03-11 15:54:13 +00:00
|
|
|
|
2020-10-10 22:49:46 +01:00
|
|
|
# We are emulating wrapGAppsHook, along with other variables to the
|
|
|
|
# wrapper
|
2020-03-30 05:13:59 +01:00
|
|
|
makeWrapperArgs = with passthru.libraries; [
|
2020-01-12 15:45:35 +00:00
|
|
|
"--prefix XDG_DATA_DIRS : ${base}/share"
|
2019-11-05 03:15:14 +00:00
|
|
|
"--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share"
|
2021-05-07 22:18:14 +01:00
|
|
|
"--prefix XDG_DATA_DIRS : ${gnome.adwaita-icon-theme}/share"
|
2019-11-05 03:15:14 +00:00
|
|
|
"--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}"
|
2019-12-06 03:53:28 +00:00
|
|
|
# wrapGAppsHook did these two as well, no idea if it matters...
|
2019-11-05 03:15:14 +00:00
|
|
|
"--prefix XDG_DATA_DIRS : ${cups}/share"
|
2021-03-16 17:42:35 +00:00
|
|
|
"--prefix GIO_EXTRA_MODULES : ${dconf}/lib/gio/modules"
|
2021-04-23 04:55:43 +01:00
|
|
|
# required to open a bug report link in firefox-wayland
|
|
|
|
"--set-default MOZ_DBUS_REMOTE 1"
|
2021-01-08 08:52:50 +00:00
|
|
|
]
|
|
|
|
++ optionals (stable)
|
|
|
|
[
|
2020-10-17 17:32:55 +01:00
|
|
|
"--set-default KISYSMOD ${footprints}/share/kicad/modules"
|
|
|
|
"--set-default KICAD_SYMBOL_DIR ${symbols}/share/kicad/library"
|
|
|
|
"--set-default KICAD_TEMPLATE_DIR ${templates}/share/kicad/template"
|
2020-03-30 05:13:59 +01:00
|
|
|
"--prefix KICAD_TEMPLATE_DIR : ${symbols}/share/kicad/template"
|
|
|
|
"--prefix KICAD_TEMPLATE_DIR : ${footprints}/share/kicad/template"
|
2019-11-05 03:15:14 +00:00
|
|
|
]
|
2021-01-08 08:52:50 +00:00
|
|
|
++ optionals (stable && with3d) [ "--set-default KISYS3DMOD ${packages3d}/share/kicad/modules/packages3d" ]
|
|
|
|
++ optionals (!stable)
|
|
|
|
[
|
|
|
|
"--set-default KICAD6_FOOTPRINT_DIR ${footprints}/share/kicad/modules"
|
|
|
|
"--set-default KICAD6_SYMBOL_DIR ${symbols}/share/kicad/library"
|
|
|
|
"--set-default KICAD6_TEMPLATE_DIR ${templates}/share/kicad/template"
|
|
|
|
"--prefix KICAD6_TEMPLATE_DIR : ${symbols}/share/kicad/template"
|
|
|
|
"--prefix KICAD6_TEMPLATE_DIR : ${footprints}/share/kicad/template"
|
|
|
|
]
|
|
|
|
++ optionals (!stable && with3d)
|
|
|
|
[
|
|
|
|
"--set-default KISYS3DMOD ${packages3d}/share/kicad/3dmodels"
|
|
|
|
"--set-default KICAD6_3DMODEL_DIR ${packages3d}/share/kicad/3dmodels"
|
|
|
|
]
|
2020-10-10 22:44:56 +01:00
|
|
|
++ optionals (withNgspice) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
|
2019-12-06 03:53:28 +00:00
|
|
|
|
2019-11-05 03:15:14 +00:00
|
|
|
# infinisil's workaround for #39493
|
|
|
|
++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]
|
|
|
|
;
|
2018-07-31 14:37:59 +01:00
|
|
|
|
2020-04-05 20:23:36 +01:00
|
|
|
# why does $makeWrapperArgs have to be added explicitly?
|
2019-12-15 03:30:15 +00:00
|
|
|
# $out and $program_PYTHONPATH don't exist when makeWrapperArgs gets set?
|
2020-10-10 23:37:15 +01:00
|
|
|
installPhase =
|
2020-04-05 20:23:36 +01:00
|
|
|
let
|
|
|
|
tools = [ "kicad" "pcbnew" "eeschema" "gerbview" "pcb_calculator" "pl_editor" "bitmap2component" ];
|
2020-10-23 14:17:47 +01:00
|
|
|
utils = [ "dxf2idf" "idf2vrml" "idfcyl" "idfrect" "kicad2step" ];
|
2020-04-05 20:23:36 +01:00
|
|
|
in
|
2020-10-10 20:50:41 +01:00
|
|
|
(concatStringsSep "\n"
|
|
|
|
(flatten [
|
2021-04-10 17:25:08 +01:00
|
|
|
"runHook preInstall"
|
|
|
|
|
2020-10-10 22:44:56 +01:00
|
|
|
(optionalString (withScripting) "buildPythonPath \"${base} $pythonPath\" \n")
|
2020-04-05 20:23:36 +01:00
|
|
|
|
|
|
|
# wrap each of the directly usable tools
|
2020-10-10 20:50:41 +01:00
|
|
|
(map
|
|
|
|
(tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs"
|
2020-10-10 22:44:56 +01:00
|
|
|
+ optionalString (withScripting) " --set PYTHONPATH \"$program_PYTHONPATH\""
|
2020-10-10 20:50:41 +01:00
|
|
|
)
|
|
|
|
tools)
|
2020-04-05 20:23:36 +01:00
|
|
|
|
|
|
|
# link in the CLI utils
|
2020-10-10 20:50:41 +01:00
|
|
|
(map (util: "ln -s ${base}/bin/${util} $out/bin/${util}") utils)
|
2021-04-10 17:25:08 +01:00
|
|
|
|
|
|
|
"runHook postInstall"
|
2020-04-05 20:23:36 +01:00
|
|
|
])
|
|
|
|
)
|
2019-11-05 03:15:14 +00:00
|
|
|
;
|
2016-03-31 03:26:54 +01:00
|
|
|
|
2021-04-10 17:25:08 +01:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share
|
|
|
|
ln -s ${base}/share/applications $out/share/applications
|
|
|
|
ln -s ${base}/share/icons $out/share/icons
|
|
|
|
ln -s ${base}/share/mime $out/share/mime
|
2021-05-17 08:38:56 +01:00
|
|
|
'' + optionalString (stable) ''
|
|
|
|
ln -s ${base}/share/appdata $out/share/appdata
|
|
|
|
'' + optionalString (!stable) ''
|
|
|
|
ln -s ${base}/share/metainfo $out/share/metainfo
|
2021-04-10 17:25:08 +01:00
|
|
|
'';
|
|
|
|
|
2020-01-04 10:34:52 +00:00
|
|
|
# can't run this for each pname
|
|
|
|
# stable and unstable are in the same versions.nix
|
|
|
|
# and kicad-small reuses stable
|
|
|
|
# with "all" it updates both, run it manually if you don't want that
|
|
|
|
# and can't git commit if this could be running in parallel with other scripts
|
|
|
|
passthru.updateScript = [ ./update.sh "all" ];
|
|
|
|
|
2020-03-28 00:39:57 +00:00
|
|
|
meta = rec {
|
|
|
|
description = (if (stable)
|
2020-10-10 20:50:41 +01:00
|
|
|
then "Open Source Electronics Design Automation suite"
|
|
|
|
else "Open Source EDA suite, development build")
|
|
|
|
+ (if (!with3d) then ", without 3D models" else "");
|
2019-12-06 03:53:28 +00:00
|
|
|
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.
|
|
|
|
'';
|
2021-04-10 19:39:02 +01:00
|
|
|
license = lib.licenses.gpl3Plus;
|
2021-04-23 04:55:43 +01:00
|
|
|
maintainers = with lib.maintainers; [ evils kiwi ];
|
2020-03-28 00:39:57 +00:00
|
|
|
# kicad is cross platform
|
2021-01-15 13:21:58 +00:00
|
|
|
platforms = lib.platforms.all;
|
2020-03-28 00:39:57 +00:00
|
|
|
# despite that, nipkgs' wxGTK for darwin is "wxmac"
|
|
|
|
# and wxPython_4_0 does not account for this
|
|
|
|
# adjusting this package to downgrade to python2Packages.wxPython (wxPython 3),
|
|
|
|
# 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
|
2010-08-22 13:09:47 +01:00
|
|
|
};
|
|
|
|
}
|