From b3e2b523e5096ceb1e079bf011f5aad2aaa47228 Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Sat, 10 Oct 2020 12:50:41 -0700 Subject: [PATCH 1/6] kicad: reformat with nixpkgs-fmt --- .../science/electronics/kicad/default.nix | 72 ++++++++++++------- .../science/electronics/kicad/libraries.nix | 13 ++-- 2 files changed, 56 insertions(+), 29 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index e5ce1f0092e..578cdbf4a5c 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -1,16 +1,29 @@ -{ lib, stdenv, gnome3, wxGTK30, wxGTK31 +{ lib +, stdenv +, 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 +, opencascade +, withOCCT ? true +, opencascade-occt +, ngspiceSupport ? true +, libngspice +, scriptingSupport ? true +, swig +, python3 +, debug ? false +, valgrind , with3d ? true , withI18n ? true }: @@ -19,18 +32,25 @@ assert ngspiceSupport -> libngspice != null; with lib; let - baseName = if (stable) then "kicad" else "kicad-unstable"; - versions = import ./versions.nix; + versions = import ./versions.nix; versionConfig = versions.${baseName}; - wxGTK = if (stable) + 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; @@ -59,7 +79,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ makeWrapper ] ++ optionals (scriptingSupport) - [ python.pkgs.wrapPython ]; + [ python.pkgs.wrapPython ]; # wrapGAppsHook added the equivalent to ${base}/share # though i noticed no difference without it @@ -94,17 +114,19 @@ stdenv.mkDerivation rec { 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 (scriptingSupport) "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 (scriptingSupport) " --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,9 +140,9 @@ 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. diff --git a/pkgs/applications/science/electronics/kicad/libraries.nix b/pkgs/applications/science/electronics/kicad/libraries.nix index 057bc15bf5f..b424cde195e 100644 --- a/pkgs/applications/science/electronics/kicad/libraries.nix +++ b/pkgs/applications/science/electronics/kicad/libraries.nix @@ -1,6 +1,11 @@ -{ lib, stdenv, cmake, gettext -, fetchFromGitHub, fetchFromGitLab -, version, libSources +{ lib +, stdenv +, cmake +, gettext +, fetchFromGitHub +, fetchFromGitLab +, version +, libSources }: # callPackage libraries { @@ -33,7 +38,7 @@ let 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 From e2fea845975ef2e95c584e7dcff6c479157988db Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Sat, 10 Oct 2020 14:49:46 -0700 Subject: [PATCH 2/6] kicad: clarify wrapGAppsHook comment --- pkgs/applications/science/electronics/kicad/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index 578cdbf4a5c..2758d7765cf 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -81,8 +81,8 @@ stdenv.mkDerivation rec { ++ optionals (scriptingSupport) [ 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" From 85d5195f70eba27b4a028247d375fb0df522ef4a Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Sat, 10 Oct 2020 15:37:15 -0700 Subject: [PATCH 3/6] kicad: remove unnecessary with lib; statements --- pkgs/applications/science/electronics/kicad/base.nix | 9 ++++----- .../science/electronics/kicad/default.nix | 11 +++++------ .../science/electronics/kicad/libraries.nix | 8 +++----- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix index 6581fb8f445..6982b0fce8c 100644 --- a/pkgs/applications/science/electronics/kicad/base.nix +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -1,5 +1,4 @@ -{ lib -, stdenv +{ stdenv , fetchFromGitLab , cmake , libGLU @@ -44,7 +43,6 @@ assert ngspiceSupport -> libngspice != null; -with lib; let versionConfig = versions.${baseName}; @@ -54,6 +52,7 @@ let libraries = callPackages ./libraries.nix versionConfig.libVersion; + inherit (stdenv.lib) optional optionals; in stdenv.mkDerivation rec { @@ -166,7 +165,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; }; } diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index 2758d7765cf..cfe44140990 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -1,5 +1,5 @@ -{ lib -, stdenv +{ stdenv +, fetchFromGitLab , gnome3 , wxGTK30 , wxGTK31 @@ -29,8 +29,6 @@ }: assert ngspiceSupport -> libngspice != null; - -with lib; let baseName = if (stable) then "kicad" else "kicad-unstable"; @@ -55,6 +53,7 @@ let python = python3; wxPython = python.pkgs.wxPython_4_0; + inherit (stdenv.lib) concatStringsSep flatten optionalString optionals; in stdenv.mkDerivation rec { @@ -109,7 +108,7 @@ 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" ]; @@ -148,7 +147,7 @@ stdenv.mkDerivation rec { 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 diff --git a/pkgs/applications/science/electronics/kicad/libraries.nix b/pkgs/applications/science/electronics/kicad/libraries.nix index b424cde195e..e47b56b5c48 100644 --- a/pkgs/applications/science/electronics/kicad/libraries.nix +++ b/pkgs/applications/science/electronics/kicad/libraries.nix @@ -1,5 +1,4 @@ -{ lib -, stdenv +{ stdenv , cmake , gettext , fetchFromGitHub @@ -15,7 +14,6 @@ # sha256 = "..."; # }; # }; -with lib; let mkLib = name: stdenv.mkDerivation { @@ -34,7 +32,7 @@ let 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 @@ -69,7 +67,7 @@ in ); nativeBuildInputs = [ cmake gettext ]; meta = { - license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 + license = stdenv.lib.licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 platforms = stdenv.lib.platforms.all; }; }; From 9d13164b27ca77ef964b532f524a22a82511542f Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Sat, 10 Oct 2020 14:44:56 -0700 Subject: [PATCH 4/6] kicad: Rename `Support` arguments to `with` Also: Use assertions instead of silently ignoring arguments that don't cooperate (occ+oce) / won't compile (aarch64 + oce). base.nix no longer provides default argument values since these are provided by default.nix. --- .../science/electronics/kicad/base.nix | 39 +++++++++---------- .../science/electronics/kicad/default.nix | 32 ++++++++++----- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix index 6982b0fce8c..ff6209ee85b 100644 --- a/pkgs/applications/science/electronics/kicad/base.nix +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -22,37 +22,36 @@ , lndir , callPackages -, stable ? true -, baseName ? "kicad" -, versions ? { } -, oceSupport ? false +, stable +, baseName +, versions +, 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; - +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; + versionConfig = versions.${baseName}; + libraries = callPackages ./libraries.nix versionConfig.libVersion; in stdenv.mkDerivation rec { @@ -93,15 +92,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) [ @@ -139,8 +138,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 diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index cfe44140990..429e57cbe6a 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -14,12 +14,16 @@ , pname ? "kicad" , stable ? true , oceSupport ? false +, withOCE ? false , opencascade -, withOCCT ? true +, withOCCT ? false +, withOCC ? true , opencascade-occt -, ngspiceSupport ? true +, ngspiceSupport ? false +, withNgspice ? true , libngspice -, scriptingSupport ? true +, scriptingSupport ? false +, withScripting ? true , swig , python3 , debug ? false @@ -28,7 +32,15 @@ , withI18n ? true }: -assert ngspiceSupport -> libngspice != null; +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"; @@ -61,7 +73,7 @@ stdenv.mkDerivation rec { base = callPackage ./base.nix { inherit versions stable baseName; inherit wxGTK python wxPython; - inherit debug withI18n withOCCT oceSupport ngspiceSupport scriptingSupport; + inherit debug withI18n withOCC withOCE withNgspice withScripting; }; inherit pname; @@ -73,11 +85,11 @@ stdenv.mkDerivation rec { dontBuild = true; dontFixup = true; - pythonPath = optionals (scriptingSupport) + pythonPath = optionals (withScripting) [ wxPython python.pkgs.six ]; nativeBuildInputs = [ makeWrapper ] - ++ optionals (scriptingSupport) + ++ optionals (withScripting) [ python.pkgs.wrapPython ]; # We are emulating wrapGAppsHook, along with other variables to the @@ -99,7 +111,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" ] @@ -115,12 +127,12 @@ stdenv.mkDerivation rec { in (concatStringsSep "\n" (flatten [ - (optionalString (scriptingSupport) "buildPythonPath \"${base} $pythonPath\" \n") + (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\"" + + optionalString (withScripting) " --set PYTHONPATH \"$program_PYTHONPATH\"" ) tools) From f2cb2c447d1b1c4fd48a84e4e9cff21bd1c5b450 Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Sat, 10 Oct 2020 16:10:53 -0700 Subject: [PATCH 5/6] kicad: add srcs parameter to allow configuring kicad versions This also exposes the full src and version parameters for each derivation, allowing them to overrideable by srcs. --- .../science/electronics/kicad/base.nix | 25 +---- .../science/electronics/kicad/default.nix | 103 +++++++++++++++++- .../science/electronics/kicad/i18n.nix | 18 +++ .../science/electronics/kicad/libraries.nix | 55 +--------- 4 files changed, 128 insertions(+), 73 deletions(-) create mode 100644 pkgs/applications/science/electronics/kicad/i18n.nix diff --git a/pkgs/applications/science/electronics/kicad/base.nix b/pkgs/applications/science/electronics/kicad/base.nix index ff6209ee85b..3d83e905103 100644 --- a/pkgs/applications/science/electronics/kicad/base.nix +++ b/pkgs/applications/science/electronics/kicad/base.nix @@ -20,11 +20,13 @@ , libXdmcp , fetchpatch , lndir -, callPackages +, callPackage , stable , baseName -, versions +, kicadSrc +, kicadVersion +, i18n , withOCE , opencascade , withOCC @@ -45,28 +47,13 @@ assert stdenv.lib.asserts.assertMsg (!(withOCE && stdenv.isAarch64)) "OCE fails assert stdenv.lib.asserts.assertMsg (!(withOCC && withOCE)) "Only one of OCC and OCE may be enabled"; let - versionConfig = versions.${baseName}; - - libraries = callPackages ./libraries.nix versionConfig.libVersion; - inherit (stdenv.lib) optional optionals; - versionConfig = versions.${baseName}; - libraries = callPackages ./libraries.nix versionConfig.libVersion; 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 diff --git a/pkgs/applications/science/electronics/kicad/default.nix b/pkgs/applications/science/electronics/kicad/default.nix index 429e57cbe6a..7bf45a8fc54 100644 --- a/pkgs/applications/science/electronics/kicad/default.nix +++ b/pkgs/applications/science/electronics/kicad/default.nix @@ -30,8 +30,45 @@ , valgrind , with3d ? true , withI18n ? true +, srcs ? { } }: +# 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="; +# }; +# }; +# }); +# } + assert withNgspice -> libngspice != null; assert stdenv.lib.assertMsg (!ngspiceSupport) "`nspiceSupport` was renamed to `withNgspice` for the sake of consistency with other kicad nix arguments."; @@ -43,9 +80,58 @@ 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; + }; + + 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) @@ -69,15 +155,22 @@ let 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 withOCC withOCE withNgspice withScripting; }; inherit pname; - version = versions.${baseName}.kicadVersion.version; + version = kicadVersion; src = base; dontUnpack = true; diff --git a/pkgs/applications/science/electronics/kicad/i18n.nix b/pkgs/applications/science/electronics/kicad/i18n.nix new file mode 100644 index 00000000000..95cea4fd7fc --- /dev/null +++ b/pkgs/applications/science/electronics/kicad/i18n.nix @@ -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; + }; +} diff --git a/pkgs/applications/science/electronics/kicad/libraries.nix b/pkgs/applications/science/electronics/kicad/libraries.nix index e47b56b5c48..b045a7d1068 100644 --- a/pkgs/applications/science/electronics/kicad/libraries.nix +++ b/pkgs/applications/science/electronics/kicad/libraries.nix @@ -1,34 +1,17 @@ { stdenv , cmake , gettext -, fetchFromGitHub -, fetchFromGitLab -, version -, libSources +, libSrc +, libVersion }: - -# callPackage libraries { -# version = "unstable"; -# libs.symbols = { -# rev = "09f9.."; -# sha256 = "..."; -# }; -# }; 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 { @@ -45,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 = stdenv.lib.licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3 - platforms = stdenv.lib.platforms.all; - }; - }; } From b90776cbbfed996320bc493ea281db908d4e8eea Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Mon, 12 Oct 2020 11:31:28 -0700 Subject: [PATCH 6/6] add 21.03 release notes for renamed kicad options --- nixos/doc/manual/release-notes/rl-2103.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-2103.xml b/nixos/doc/manual/release-notes/rl-2103.xml index 26da246076a..dd91bf44c12 100644 --- a/nixos/doc/manual/release-notes/rl-2103.xml +++ b/nixos/doc/manual/release-notes/rl-2103.xml @@ -71,6 +71,17 @@ for consistency with other X11 resources. + + + A number of options have been renamed in the kicad interface. oceSupport + has been renamed to withOCE, withOCCT has been renamed + to withOCC, ngspiceSupport has been renamed to + withNgspice, and scriptingSupport has been renamed to + withScripting. Additionally, kicad/base.nix no longer + provides default argument values since these are provided by + kicad/default.nix. + +