From 9d13164b27ca77ef964b532f524a22a82511542f Mon Sep 17 00:00:00 2001 From: Matt Huszagh Date: Sat, 10 Oct 2020 14:44:56 -0700 Subject: [PATCH] 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 6982b0fce8c0..ff6209ee85b6 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 cfe441409901..429e57cbe6a4 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)