-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
kicad: fix #49089 by adding libraries files #57452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Other possible implementations include:
Also note that license for libraries is CC-BY-SA-4.0 and must be stated. The i18n does not seem to have any license. I also suggest using the package with libraries by default, as it should be what most user expect. |
OK, I finally used the The 3 top-levels packages are now:
Note: interested people can diff between master and dd60fbb, as this commit mostly reverts changed I have done earlier. I added the libraries license. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes a lot of sense, especially after last iteration that simplifies things. I think we don't need a separate versions without libs or without 3d, those should be always provided.
I don't fully agree for removing version without 3D. I agree that the version without libraries is now useless because the user can override the libraries paths, while it was not possible (I think) in my first draft because of the wrapper. Furthermore, they are mandatory for any basic usage, except for advanced users who could use custom/development libraries. |
For the record, I tried enabling the tests and they fail. |
@ThibautMarty Wow. I did not realize there were so many 3d models available. Then, of course, this should be optional. Perhaps it would also make sense to set But you do agree on removing the version without libraries? Even if you work with with only custom component schematics you still likely may need the standard ones once in a while. |
Agreed. I'm not sure if But the easiest solution may be to remove |
Maybe something like clearing |
OK, I think we're done. I can squash the commits and rebase if people are OK to merge. |
Hum, on second thought, it may be good to have a package with the 3D packages. |
Oh wait, |
This splits the KiCad package in several derivations: - original package (main KiCad package) - internationalization package - templates - schematic symbols libraries - PCB footprints libraries - 3D models libraries From these derivations, 2 packages are exposed in top level: - `kicad` (main KiCad package + all libraries except 3D models) - `kicad-with-3dpackages` (kicad + all libraries) The 3D models can also be installed separately with `kicad.packages3d`. This prevents a new compilation of KiCad, but the user must set the `KISYS3DMOD` environment variable or option accordingly.
This moves module definition into passthru. Otherwise building kicad would still require all modules to be built first even if they are not used. Also this drops preferLocalBuild from packages3d. hydraPlatforms should do what we need to. preferLocalBuild would addtitionaly disable remote builders, which is probably not what we want.
@ThibautMarty There was a small problem with your latest version of this PR: because packages3d was an attribute given to kicad derivation unconditionally, that package would need to be instantiated before kicad could be built. I had to move those things to passthru so that they are not required unless used. I also did bunch of other changes on my way. Let me know if you think they are usable. I did some testing on this and was able to place some symbols and footprints just fine. I was not able to render any 3d components even though files are in place. |
I agree. For the 3D rendering problem, there is another issue: #49090. I tried with the proposed workaround and it worked fine (before your changes, but they should not break things). We may consider including the documentation, as requested by developers. This adds ~300MB to the package. (A bit off topic) I tried to upgrade to 5.1.0, but got stuck with wxWidget/wxPython issues:
I did not have time to investigate further since I tried that. Here is the current version: { wxGTK, lib, stdenv, fetchurl, fetchFromGitHub, cmake, libGLU_combined, zlib
, libX11, gettext, glew, glm, cairo, curl, openssl, boost, pkgconfig
, doxygen, pcre, libpthreadstubs, libXdmcp
, wrapGAppsHook
, oceSupport ? true, opencascade
, ngspiceSupport ? true, libngspice
, swig, python, pythonPackages
, lndir
}:
assert ngspiceSupport -> libngspice != null;
with lib;
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);
in stdenv.mkDerivation rec {
name = "kicad-${version}";
series = "5.0";
version = "5.1.0";
src = fetchurl {
url = "https://launchpad.net/kicad/${series}/${version}/+download/kicad-${version}.tar.xz";
sha256 = "1g8cka71wy3mzwf4qgr9dqpskpxmwz0qpdxjkr6i8brpwy7037ks";
};
postPatch = ''
substituteInPlace CMakeModules/KiCadVersion.cmake \
--replace no-vcs-found ${version}
'';
cmakeFlags = [
"-DKICAD_SCRIPTING=ON"
"-DKICAD_SCRIPTING_MODULES=ON"
"-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON"
] ++ optionals (oceSupport) [ "-DKICAD_USE_OCE=ON" "-DOCE_DIR=${opencascade}" ]
++ optional (ngspiceSupport) "-DKICAD_SPICE=ON";
nativeBuildInputs = [
cmake
doxygen
pkgconfig
wrapGAppsHook
pythonPackages.wrapPython
lndir
];
pythonPath = [ pythonPackages.wxPython ];
propagatedBuildInputs = [ pythonPackages.wxPython ];
buildInputs = [
libGLU_combined zlib libX11 wxGTK pcre libXdmcp glew glm libpthreadstubs
cairo curl openssl boost
swig python
] ++ optional (oceSupport) opencascade
++ optional (ngspiceSupport) libngspice;
# this breaks other applications in kicad
dontWrapGApps = true;
passthru = {
i18n = mkLib version "i18n" "1pyklms6qb03ppxh6c5wpfj8ncdxa2410pn2xs6ia723wk9x48by" {
buildInputs = [
gettext
];
meta.license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3
};
symbols = mkLib version "symbols" "0czq7aaq5xdffrgfp7vc4mjbdihgzi2c1qc8d7a9q4cdb6qxh01y" {
meta.license = licenses.cc-by-sa-40;
};
footprints = mkLib version "footprints" "1xdrw0y7ngkjlz17sxfvvxyjbjk4akh38xppi5px64jjw0ca9wvn" {
meta.license = licenses.cc-by-sa-40;
};
templates = mkLib version "templates" "1nva4ckq0l2lrah0l05355cawlwd7qfxcagcv32m8hcrn781455q" {
meta.license = licenses.cc-by-sa-40;
};
packages3d = mkLib version "packages3d" "0ni8bjkvab7fqr8q3ypc402yz1j630szs0rzzzbz44lz14mkykzw" {
hydraPlatforms = []; # this is a ~1 GiB download, occupies ~5 GiB in store
meta.license = licenses.cc-by-sa-40;
};
};
modules = with passthru; [ i18n symbols footprints templates ];
postInstall = ''
mkdir -p $out/share
for module in $modules; do
lndir $module/share $out/share
done
'';
preFixup = ''
buildPythonPath "$out $pythonPath"
gappsWrapperArgs+=(--set PYTHONPATH "$program_PYTHONPATH")
wrapProgram "$out/bin/kicad" "''${gappsWrapperArgs[@]}"
'';
meta = {
description = "Free Software EDA Suite";
homepage = http://www.kicad-pcb.org/;
license = licenses.gpl2;
maintainers = with maintainers; [ berce ];
platforms = with platforms; linux;
};
} |
@ThibautMarty I'm not an active use of kicad, so you'll need to help me here. Do you think this PR as is resolves #49090? Is this ready to be merged? |
I just successfully used this for a PCB. It's a bit of a shame that we don't have 3D models without recompiling kicad, but at least we've got symbols and footprints now out of the box.. @ThibautMarty I'd like to merge this soon. Is there anything broken that I've missed? We can do the 5.1.2 upgrade and documentation afterwards as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any outstanding issues with this. Should be good to go as long as somebody thinks this is useful.
This splits the KiCad package in several derivations:
From these derivations, 3 packages are proposed in top level:
models can be heavy (currently 5.1GiB) and potentially unused
Motivation for this change
KiCad's i18n files and libraries where missing. We needed to download the libraires manually and configure paths in the software. This PR adds them in the package output.
Things done
The different top level packages are combined with
symlinkJoin
, which joins two outputs by creating symbolic links.The advantage is that only one compilation of the main package is needed, as other packages are symlinked to the main one.
The drawback is that, by default, kicad looks for libraries in the
/share
directory of its binary.Thus I added a wrapper that sets
KICAD_SYMBOL_DIR
and other environment variables to correctly point the libraries. This prevent user to use its own library (but this is still possible by using)The internationalization works. The menu used to exist, but did not have effect.
I would like to have comments on:
symlinkJoin
the best approach?meta
attribute?top-level.nix
approach correct?CC @berce (maintener) and @crawford (opened #49089)
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)