From 2f5439a9509f8e5d26c6a53df2fabda8d25b36a1 Mon Sep 17 00:00:00 2001 From: Thibaut Marty Date: Mon, 11 Mar 2019 16:54:13 +0100 Subject: [PATCH 1/4] kicad: fix #49089 by adding libraries files 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. --- .../science/electronics/kicad/default.nix | 51 +++++++++++++++++-- pkgs/top-level/all-packages.nix | 1 + 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index e77f4a603a8..08daabf6f01 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -1,16 +1,31 @@ -{ wxGTK, lib, stdenv, fetchurl, cmake, libGLU_combined, zlib +{ 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, withLibraries ? true, with3DPackages ? false }: assert ngspiceSupport -> libngspice != null; with lib; -stdenv.mkDerivation rec { +let + mkLib = version: name: sha256: stdenv.mkDerivation { + name = "kicad-${name}-${version}"; + src = fetchFromGitHub { + owner = "KiCad"; + repo = "kicad-${name}"; + rev = "${version}"; + inherit sha256 name; + }; + nativeBuildInputs = [ + cmake + ]; + }; + +in stdenv.mkDerivation rec { name = "kicad-${version}"; series = "5.0"; version = "5.0.2"; @@ -41,12 +56,13 @@ stdenv.mkDerivation rec { pkgconfig wrapGAppsHook pythonPackages.wrapPython + lndir ]; pythonPath = [ pythonPackages.wxPython ]; propagatedBuildInputs = [ pythonPackages.wxPython ]; buildInputs = [ - libGLU_combined zlib libX11 wxGTK pcre libXdmcp gettext glew glm libpthreadstubs + libGLU_combined zlib libX11 wxGTK pcre libXdmcp glew glm libpthreadstubs cairo curl openssl boost swig python ] ++ optional (oceSupport) opencascade @@ -55,6 +71,33 @@ stdenv.mkDerivation rec { # this breaks other applications in kicad dontWrapGApps = true; + i18n = (mkLib version "i18n" "1hkc240gymhmyv6r858mq5d2slz0vjqc47ah8wn82vvmb83fpnjy").overrideAttrs (_: { + buildInputs = [ + gettext + ]; + }); + + symbols = mkLib version "symbols" "1rjh2pjcrc3bhcgyyskj5pssm7vffrjk0ymwr70fb7sjpmk96yjk"; + + footprints = mkLib version "footprints" "19khqyrbrqsdzxvm1b1vxfscxhss705fqky0ilrbvnbvf27fnx8w"; + + templates = mkLib version "templates" "0rlzq1n09n0sf2kj5c9bvbnkvs6cpycjxmxwcswql0fbpcp0sql7"; + + packages3d = (mkLib version "packages3d" "135jyrljgknnv2y35skhnwcxg16yxxkfbcx07nad3vr4r76zk3am").overrideAttrs (_: { + hydraPlatforms = []; # Disable big package3d library + preferLocalBuild = true; + }); + + postInstall = '' + lndir -silent $i18n/share $out/share + '' + optionalString withLibraries '' + lndir -silent $symbols/share $out/share + lndir -silent $footprints/share $out/share + lndir -silent $templates/share $out/share + '' + optionalString with3DPackages '' + lndir -silent $packages3d/share $out/share + ''; + preFixup = '' buildPythonPath "$out $pythonPath" gappsWrapperArgs+=(--set PYTHONPATH "$program_PYTHONPATH") @@ -65,7 +108,7 @@ stdenv.mkDerivation rec { meta = { description = "Free Software EDA Suite"; homepage = http://www.kicad-pcb.org/; - license = licenses.gpl2; + license = [ licenses.gpl2 ] ++ optional (withLibraries || with3DPackages) licenses.cc-by-sa-40; maintainers = with maintainers; [ berce ]; platforms = with platforms; linux; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fb0d1246e35..555acfe68d9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22031,6 +22031,7 @@ in wxGTK = wxGTK30; boost = boost160; }; + kicad-with-3dpackages = kicad.override { with3DPackages = true; }; kicad-unstable = python.pkgs.callPackage ../applications/science/electronics/kicad/unstable.nix { wxGTK = wxGTK30; From d0fc807347a4f1f2dc44bb59564268c64423caac Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sat, 23 Mar 2019 23:54:31 -0400 Subject: [PATCH 2/4] kicad: make module list overridable 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. --- .../science/electronics/kicad/default.nix | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index 08daabf6f01..de47589aef8 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -5,14 +5,14 @@ , oceSupport ? true, opencascade , ngspiceSupport ? true, libngspice , swig, python, pythonPackages -, lndir, withLibraries ? true, with3DPackages ? false +, lndir, with3DPackages ? false }: assert ngspiceSupport -> libngspice != null; with lib; let - mkLib = version: name: sha256: stdenv.mkDerivation { + mkLib = version: name: sha256: attrs: stdenv.mkDerivation ({ name = "kicad-${name}-${version}"; src = fetchFromGitHub { owner = "KiCad"; @@ -23,7 +23,7 @@ let nativeBuildInputs = [ cmake ]; - }; + } // attrs); in stdenv.mkDerivation rec { name = "kicad-${version}"; @@ -71,31 +71,37 @@ in stdenv.mkDerivation rec { # this breaks other applications in kicad dontWrapGApps = true; - i18n = (mkLib version "i18n" "1hkc240gymhmyv6r858mq5d2slz0vjqc47ah8wn82vvmb83fpnjy").overrideAttrs (_: { - buildInputs = [ - gettext - ]; - }); + passthru = { + i18n = mkLib version "i18n" "1hkc240gymhmyv6r858mq5d2slz0vjqc47ah8wn82vvmb83fpnjy" { + buildInputs = [ + gettext + ]; + meta.license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 + }; + symbols = mkLib version "symbols" "1rjh2pjcrc3bhcgyyskj5pssm7vffrjk0ymwr70fb7sjpmk96yjk" { + meta.license = licenses.cc-by-sa-40; + }; + footprints = mkLib version "footprints" "19khqyrbrqsdzxvm1b1vxfscxhss705fqky0ilrbvnbvf27fnx8w" { + meta.license = licenses.cc-by-sa-40; + }; + templates = mkLib version "templates" "0rlzq1n09n0sf2kj5c9bvbnkvs6cpycjxmxwcswql0fbpcp0sql7" { + meta.license = licenses.cc-by-sa-40; + }; + packages3d = mkLib version "packages3d" "135jyrljgknnv2y35skhnwcxg16yxxkfbcx07nad3vr4r76zk3am" { + hydraPlatforms = []; # this is a ~1 GiB download, occupies ~5 GiB in store + meta.license = licenses.cc-by-sa-40; + }; + }; - symbols = mkLib version "symbols" "1rjh2pjcrc3bhcgyyskj5pssm7vffrjk0ymwr70fb7sjpmk96yjk"; - - footprints = mkLib version "footprints" "19khqyrbrqsdzxvm1b1vxfscxhss705fqky0ilrbvnbvf27fnx8w"; - - templates = mkLib version "templates" "0rlzq1n09n0sf2kj5c9bvbnkvs6cpycjxmxwcswql0fbpcp0sql7"; - - packages3d = (mkLib version "packages3d" "135jyrljgknnv2y35skhnwcxg16yxxkfbcx07nad3vr4r76zk3am").overrideAttrs (_: { - hydraPlatforms = []; # Disable big package3d library - preferLocalBuild = true; - }); + modules = with passthru; + [ i18n symbols footprints templates ] + ++ optional with3DPackages packages3d; postInstall = '' - lndir -silent $i18n/share $out/share - '' + optionalString withLibraries '' - lndir -silent $symbols/share $out/share - lndir -silent $footprints/share $out/share - lndir -silent $templates/share $out/share - '' + optionalString with3DPackages '' - lndir -silent $packages3d/share $out/share + mkdir -p $out/share + for module in $modules; do + lndir $module/share $out/share + done ''; preFixup = '' @@ -108,7 +114,7 @@ in stdenv.mkDerivation rec { meta = { description = "Free Software EDA Suite"; homepage = http://www.kicad-pcb.org/; - license = [ licenses.gpl2 ] ++ optional (withLibraries || with3DPackages) licenses.cc-by-sa-40; + license = licenses.gpl2; maintainers = with maintainers; [ berce ]; platforms = with platforms; linux; }; From 38b329214978cae22da57465b9b88068cfab6b3f Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 24 Mar 2019 00:09:55 -0400 Subject: [PATCH 3/4] kicad-with-3dpackages: rename to kicad-with-packages3d --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 555acfe68d9..6dc2f333519 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22031,7 +22031,7 @@ in wxGTK = wxGTK30; boost = boost160; }; - kicad-with-3dpackages = kicad.override { with3DPackages = true; }; + kicad-with-packages3d = kicad.override { with3DPackages = true; }; kicad-unstable = python.pkgs.callPackage ../applications/science/electronics/kicad/unstable.nix { wxGTK = wxGTK30; From 9ba406ff1c5f2621f3baf44e2bad32c1e251412f Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Sun, 24 Mar 2019 01:33:49 -0400 Subject: [PATCH 4/4] kicad: replace with3DPackages option with an override --- pkgs/applications/science/electronics/kicad/default.nix | 6 ++---- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index de47589aef8..fa4fce26734 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -5,7 +5,7 @@ , oceSupport ? true, opencascade , ngspiceSupport ? true, libngspice , swig, python, pythonPackages -, lndir, with3DPackages ? false +, lndir }: assert ngspiceSupport -> libngspice != null; @@ -93,9 +93,7 @@ in stdenv.mkDerivation rec { }; }; - modules = with passthru; - [ i18n symbols footprints templates ] - ++ optional with3DPackages packages3d; + modules = with passthru; [ i18n symbols footprints templates ]; postInstall = '' mkdir -p $out/share diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6dc2f333519..363717aa411 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22031,7 +22031,7 @@ in wxGTK = wxGTK30; boost = boost160; }; - kicad-with-packages3d = kicad.override { with3DPackages = true; }; + kicad-with-packages3d = kicad.overrideAttrs (old: { modules = old.modules ++ [ old.passthru.packages3d ]; }); kicad-unstable = python.pkgs.callPackage ../applications/science/electronics/kicad/unstable.nix { wxGTK = wxGTK30;