mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 07:53:19 +00:00
Merge pull request #100066 from matthuszagh/kicad-srcs
This commit is contained in:
commit
58b8ae4127
@ -71,6 +71,17 @@
|
||||
for consistency with other X11 resources.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
A number of options have been renamed in the kicad interface. <literal>oceSupport</literal>
|
||||
has been renamed to <literal>withOCE</literal>, <literal>withOCCT</literal> has been renamed
|
||||
to <literal>withOCC</literal>, <literal>ngspiceSupport</literal> has been renamed to
|
||||
<literal>withNgspice</literal>, and <literal>scriptingSupport</literal> has been renamed to
|
||||
<literal>withScripting</literal>. Additionally, <literal>kicad/base.nix</literal> no longer
|
||||
provides default argument values since these are provided by
|
||||
<literal>kicad/default.nix</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
{ stdenv
|
||||
, fetchFromGitLab
|
||||
, cmake
|
||||
, libGLU
|
||||
@ -21,54 +20,40 @@
|
||||
, libXdmcp
|
||||
, fetchpatch
|
||||
, lndir
|
||||
, callPackages
|
||||
, callPackage
|
||||
|
||||
, stable ? true
|
||||
, baseName ? "kicad"
|
||||
, versions ? { }
|
||||
, oceSupport ? false
|
||||
, stable
|
||||
, baseName
|
||||
, kicadSrc
|
||||
, kicadVersion
|
||||
, i18n
|
||||
, withOCE
|
||||
, opencascade
|
||||
, withOCCT ? true
|
||||
, withOCC
|
||||
, opencascade-occt
|
||||
, ngspiceSupport ? true
|
||||
, withNgspice
|
||||
, libngspice
|
||||
, scriptingSupport ? true
|
||||
, withScripting
|
||||
, swig
|
||||
, python
|
||||
, wxPython
|
||||
, debug ? false
|
||||
, debug
|
||||
, valgrind
|
||||
, withI18n ? true
|
||||
, withI18n
|
||||
, gtk3
|
||||
}:
|
||||
|
||||
assert ngspiceSupport -> libngspice != null;
|
||||
|
||||
with lib;
|
||||
assert stdenv.lib.asserts.assertMsg (!(withOCE && stdenv.isAarch64)) "OCE fails a test on Aarch64";
|
||||
assert stdenv.lib.asserts.assertMsg (!(withOCC && withOCE))
|
||||
"Only one of OCC and OCE may be enabled";
|
||||
let
|
||||
versionConfig = versions.${baseName};
|
||||
|
||||
# oce on aarch64 fails a test
|
||||
withOCE = oceSupport && !stdenv.isAarch64;
|
||||
withOCC = (withOCCT && !withOCE) || (oceSupport && stdenv.isAarch64);
|
||||
|
||||
libraries = callPackages ./libraries.nix versionConfig.libVersion;
|
||||
|
||||
inherit (stdenv.lib) optional optionals;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
|
||||
i18n = libraries.i18n;
|
||||
|
||||
pname = "kicad-base";
|
||||
version = "${builtins.substring 0 10 versions.${baseName}.kicadVersion.src.rev}";
|
||||
version = kicadVersion;
|
||||
|
||||
src = fetchFromGitLab (
|
||||
{
|
||||
group = "kicad";
|
||||
owner = "code";
|
||||
repo = "kicad";
|
||||
} // versionConfig.kicadVersion.src
|
||||
);
|
||||
src = kicadSrc;
|
||||
|
||||
# quick fix for #72248
|
||||
# should be removed if a a more permanent fix is published
|
||||
@ -94,15 +79,15 @@ stdenv.mkDerivation rec {
|
||||
makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ];
|
||||
|
||||
cmakeFlags =
|
||||
optionals (scriptingSupport) [
|
||||
optionals (withScripting) [
|
||||
"-DKICAD_SCRIPTING=ON"
|
||||
"-DKICAD_SCRIPTING_MODULES=ON"
|
||||
"-DKICAD_SCRIPTING_PYTHON3=ON"
|
||||
"-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON"
|
||||
]
|
||||
++ optional (!scriptingSupport)
|
||||
++ optional (!withScripting)
|
||||
"-DKICAD_SCRIPTING=OFF"
|
||||
++ optional (ngspiceSupport) "-DKICAD_SPICE=ON"
|
||||
++ optional (withNgspice) "-DKICAD_SPICE=ON"
|
||||
++ optional (!withOCE) "-DKICAD_USE_OCE=OFF"
|
||||
++ optional (!withOCC) "-DKICAD_USE_OCC=OFF"
|
||||
++ optionals (withOCE) [
|
||||
@ -140,8 +125,8 @@ stdenv.mkDerivation rec {
|
||||
boost
|
||||
gtk3
|
||||
]
|
||||
++ optionals (scriptingSupport) [ swig python wxPython ]
|
||||
++ optional (ngspiceSupport) libngspice
|
||||
++ optionals (withScripting) [ swig python wxPython ]
|
||||
++ optional (withNgspice) libngspice
|
||||
++ optional (withOCE) opencascade
|
||||
++ optional (withOCC) opencascade-occt
|
||||
++ optional (debug) valgrind
|
||||
@ -166,7 +151,7 @@ stdenv.mkDerivation rec {
|
||||
the libraries are passed via an env var in the wrapper, default.nix
|
||||
'';
|
||||
homepage = "https://www.kicad-pcb.org/";
|
||||
license = licenses.agpl3;
|
||||
platforms = platforms.all;
|
||||
license = stdenv.lib.licenses.agpl3;
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
};
|
||||
}
|
||||
|
@ -1,52 +1,176 @@
|
||||
{ lib, stdenv, gnome3, wxGTK30, wxGTK31
|
||||
{ stdenv
|
||||
, fetchFromGitLab
|
||||
, gnome3
|
||||
, wxGTK30
|
||||
, wxGTK31
|
||||
, makeWrapper
|
||||
, gsettings-desktop-schemas, hicolor-icon-theme
|
||||
, callPackage, callPackages
|
||||
, librsvg, cups
|
||||
, gsettings-desktop-schemas
|
||||
, hicolor-icon-theme
|
||||
, callPackage
|
||||
, callPackages
|
||||
, librsvg
|
||||
, cups
|
||||
|
||||
, pname ? "kicad"
|
||||
, stable ? true
|
||||
, oceSupport ? false, opencascade
|
||||
, withOCCT ? true, opencascade-occt
|
||||
, ngspiceSupport ? true, libngspice
|
||||
, scriptingSupport ? true, swig, python3
|
||||
, debug ? false, valgrind
|
||||
, oceSupport ? false
|
||||
, withOCE ? false
|
||||
, opencascade
|
||||
, withOCCT ? false
|
||||
, withOCC ? true
|
||||
, opencascade-occt
|
||||
, ngspiceSupport ? false
|
||||
, withNgspice ? true
|
||||
, libngspice
|
||||
, scriptingSupport ? false
|
||||
, withScripting ? true
|
||||
, swig
|
||||
, python3
|
||||
, debug ? false
|
||||
, valgrind
|
||||
, with3d ? true
|
||||
, withI18n ? true
|
||||
, srcs ? { }
|
||||
}:
|
||||
|
||||
assert ngspiceSupport -> libngspice != null;
|
||||
# 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:
|
||||
|
||||
with lib;
|
||||
# {
|
||||
# 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=";
|
||||
# };
|
||||
# };
|
||||
# });
|
||||
# }
|
||||
|
||||
assert withNgspice -> libngspice != null;
|
||||
assert stdenv.lib.assertMsg (!ngspiceSupport)
|
||||
"`nspiceSupport` was renamed to `withNgspice` for the sake of consistency with other kicad nix arguments.";
|
||||
assert stdenv.lib.assertMsg (!oceSupport)
|
||||
"`oceSupport` was renamed to `withOCE` for the sake of consistency with other kicad nix arguments.";
|
||||
assert stdenv.lib.assertMsg (!scriptingSupport)
|
||||
"`scriptingSupport` was renamed to `withScripting` for the sake of consistency with other kicad nix arguments.";
|
||||
assert stdenv.lib.assertMsg (!withOCCT)
|
||||
"`withOCCT` was renamed to `withOCC` for the sake of consistency with upstream cmake options.";
|
||||
let
|
||||
|
||||
baseName = if (stable) then "kicad" else "kicad-unstable";
|
||||
versionsImport = import ./versions.nix;
|
||||
|
||||
versions = import ./versions.nix;
|
||||
versionConfig = versions.${baseName};
|
||||
# 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;
|
||||
};
|
||||
|
||||
wxGTK = if (stable)
|
||||
i18nSrcFetch = fetchFromGitLab {
|
||||
group = "kicad";
|
||||
owner = "code";
|
||||
repo = "kicad-i18n";
|
||||
rev = versionsImport.${baseName}.libVersion.libSources.i18n.rev;
|
||||
sha256 = versionsImport.${baseName}.libVersion.libSources.i18n.sha256;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
wxGTK =
|
||||
if (stable)
|
||||
# wxGTK3x may default to withGtk2 = false, see #73145
|
||||
then wxGTK30.override { withGtk2 = false; }
|
||||
then
|
||||
wxGTK30.override
|
||||
{
|
||||
withGtk2 = false;
|
||||
}
|
||||
# wxGTK31 currently introduces an issue with opening the python interpreter in pcbnew
|
||||
# but brings high DPI support?
|
||||
else wxGTK31.override { withGtk2 = false; };
|
||||
else
|
||||
wxGTK31.override {
|
||||
withGtk2 = false;
|
||||
};
|
||||
|
||||
python = python3;
|
||||
wxPython = python.pkgs.wxPython_4_0;
|
||||
|
||||
inherit (stdenv.lib) concatStringsSep flatten optionalString optionals;
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
|
||||
passthru.libraries = callPackages ./libraries.nix versionConfig.libVersion;
|
||||
# Common libraries, referenced during runtime, via the wrapper.
|
||||
passthru.libraries = callPackages ./libraries.nix { inherit libSrc libVersion; };
|
||||
passthru.i18n = callPackage ./i18n.nix {
|
||||
src = i18nSrc;
|
||||
version = i18nVersion;
|
||||
};
|
||||
base = callPackage ./base.nix {
|
||||
inherit versions stable baseName;
|
||||
inherit stable baseName;
|
||||
inherit kicadSrc kicadVersion;
|
||||
inherit (passthru) i18n;
|
||||
inherit wxGTK python wxPython;
|
||||
inherit debug withI18n withOCCT oceSupport ngspiceSupport scriptingSupport;
|
||||
inherit debug withI18n withOCC withOCE withNgspice withScripting;
|
||||
};
|
||||
|
||||
inherit pname;
|
||||
version = versions.${baseName}.kicadVersion.version;
|
||||
version = kicadVersion;
|
||||
|
||||
src = base;
|
||||
dontUnpack = true;
|
||||
@ -54,15 +178,15 @@ stdenv.mkDerivation rec {
|
||||
dontBuild = true;
|
||||
dontFixup = true;
|
||||
|
||||
pythonPath = optionals (scriptingSupport)
|
||||
pythonPath = optionals (withScripting)
|
||||
[ wxPython python.pkgs.six ];
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ]
|
||||
++ optionals (scriptingSupport)
|
||||
[ python.pkgs.wrapPython ];
|
||||
++ optionals (withScripting)
|
||||
[ python.pkgs.wrapPython ];
|
||||
|
||||
# wrapGAppsHook added the equivalent to ${base}/share
|
||||
# though i noticed no difference without it
|
||||
# We are emulating wrapGAppsHook, along with other variables to the
|
||||
# wrapper
|
||||
makeWrapperArgs = with passthru.libraries; [
|
||||
"--prefix XDG_DATA_DIRS : ${base}/share"
|
||||
"--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share"
|
||||
@ -80,7 +204,7 @@ stdenv.mkDerivation rec {
|
||||
"--prefix KICAD_TEMPLATE_DIR : ${footprints}/share/kicad/template"
|
||||
]
|
||||
++ optionals (with3d) [ "--set KISYS3DMOD ${packages3d}/share/kicad/modules/packages3d" ]
|
||||
++ optionals (ngspiceSupport) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
|
||||
++ optionals (withNgspice) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
|
||||
|
||||
# infinisil's workaround for #39493
|
||||
++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]
|
||||
@ -89,22 +213,24 @@ stdenv.mkDerivation rec {
|
||||
# why does $makeWrapperArgs have to be added explicitly?
|
||||
# $out and $program_PYTHONPATH don't exist when makeWrapperArgs gets set?
|
||||
# kicad-ogltest's source seems to indicate that crashing is expected behaviour...
|
||||
installPhase = with lib;
|
||||
installPhase =
|
||||
let
|
||||
tools = [ "kicad" "pcbnew" "eeschema" "gerbview" "pcb_calculator" "pl_editor" "bitmap2component" ];
|
||||
utils = [ "dxf2idf" "idf2vrml" "idfcyl" "idfrect" "kicad2step" "kicad-ogltest" ];
|
||||
in
|
||||
( concatStringsSep "\n"
|
||||
( flatten [
|
||||
( optionalString (scriptingSupport) "buildPythonPath \"${base} $pythonPath\" \n" )
|
||||
(concatStringsSep "\n"
|
||||
(flatten [
|
||||
(optionalString (withScripting) "buildPythonPath \"${base} $pythonPath\" \n")
|
||||
|
||||
# wrap each of the directly usable tools
|
||||
( map ( tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs"
|
||||
+ optionalString (scriptingSupport) " --set PYTHONPATH \"$program_PYTHONPATH\""
|
||||
) tools )
|
||||
(map
|
||||
(tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs"
|
||||
+ optionalString (withScripting) " --set PYTHONPATH \"$program_PYTHONPATH\""
|
||||
)
|
||||
tools)
|
||||
|
||||
# link in the CLI utils
|
||||
( map ( util: "ln -s ${base}/bin/${util} $out/bin/${util}" ) utils )
|
||||
(map (util: "ln -s ${base}/bin/${util} $out/bin/${util}") utils)
|
||||
])
|
||||
)
|
||||
;
|
||||
@ -118,15 +244,15 @@ stdenv.mkDerivation rec {
|
||||
|
||||
meta = rec {
|
||||
description = (if (stable)
|
||||
then "Open Source Electronics Design Automation suite"
|
||||
else "Open Source EDA suite, development build")
|
||||
+ (if (!with3d) then ", without 3D models" else "");
|
||||
then "Open Source Electronics Design Automation suite"
|
||||
else "Open Source EDA suite, development build")
|
||||
+ (if (!with3d) then ", without 3D models" else "");
|
||||
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.
|
||||
'';
|
||||
license = licenses.agpl3;
|
||||
license = stdenv.lib.licenses.agpl3;
|
||||
# berce seems inactive...
|
||||
maintainers = with stdenv.lib.maintainers; [ evils kiwi berce ];
|
||||
# kicad is cross platform
|
||||
|
18
pkgs/applications/science/electronics/kicad/i18n.nix
Normal file
18
pkgs/applications/science/electronics/kicad/i18n.nix
Normal file
@ -0,0 +1,18 @@
|
||||
{ stdenv
|
||||
, cmake
|
||||
, gettext
|
||||
, src
|
||||
, version
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
inherit src version;
|
||||
|
||||
pname = "kicad-i18n";
|
||||
|
||||
nativeBuildInputs = [ cmake gettext ];
|
||||
meta = with stdenv.lib; {
|
||||
license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
@ -1,39 +1,25 @@
|
||||
{ lib, stdenv, cmake, gettext
|
||||
, fetchFromGitHub, fetchFromGitLab
|
||||
, version, libSources
|
||||
{ stdenv
|
||||
, cmake
|
||||
, gettext
|
||||
, libSrc
|
||||
, libVersion
|
||||
}:
|
||||
|
||||
# callPackage libraries {
|
||||
# version = "unstable";
|
||||
# libs.symbols = {
|
||||
# rev = "09f9..";
|
||||
# sha256 = "...";
|
||||
# };
|
||||
# };
|
||||
with lib;
|
||||
let
|
||||
mkLib = name:
|
||||
stdenv.mkDerivation {
|
||||
pname = "kicad-${name}";
|
||||
# Use the revision instead of `version` (which is an ISO 8601 date)
|
||||
# to prevent duplicating the library when just the date changed
|
||||
version = "${builtins.substring 0 10 libSources.${name}.rev}";
|
||||
src = fetchFromGitHub (
|
||||
{
|
||||
owner = "KiCad";
|
||||
repo = "kicad-${name}";
|
||||
rev = version;
|
||||
inherit name;
|
||||
} // (libSources.${name} or { })
|
||||
);
|
||||
version = libVersion;
|
||||
|
||||
src = libSrc name;
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
meta = rec {
|
||||
license = licenses.cc-by-sa-40;
|
||||
license = stdenv.lib.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;
|
||||
hydraPlatforms = if (name == "packages3d") then [ ] else platforms;
|
||||
};
|
||||
};
|
||||
in
|
||||
@ -42,30 +28,4 @@ in
|
||||
templates = mkLib "templates";
|
||||
footprints = mkLib "footprints";
|
||||
packages3d = mkLib "packages3d";
|
||||
|
||||
# i18n is a special case, not actually a library
|
||||
# more a part of kicad proper, but also optional and separate
|
||||
# since their move to gitlab they're keeping it in a separate path
|
||||
# kicad has no way to find i18n except through a path relative to its install path
|
||||
# therefore this is being linked into ${kicad-base}/share/
|
||||
# and defined here to make use of the rev & sha256's brought here for the libs
|
||||
i18n = let name = "i18n"; in
|
||||
stdenv.mkDerivation {
|
||||
pname = "kicad-${name}";
|
||||
version = "${builtins.substring 0 10 libSources.${name}.rev}";
|
||||
src = fetchFromGitLab (
|
||||
{
|
||||
group = "kicad";
|
||||
owner = "code";
|
||||
repo = "kicad-${name}";
|
||||
rev = version;
|
||||
inherit name;
|
||||
} // (libSources.${name} or { })
|
||||
);
|
||||
nativeBuildInputs = [ cmake gettext ];
|
||||
meta = {
|
||||
license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user