Skip to content

Instantly share code, notes, and snippets.

@hannesweisbach
Last active September 18, 2020 08:43
Show Gist options
  • Save hannesweisbach/e1a9203e3bc2a00f482309cc5a1bfc73 to your computer and use it in GitHub Desktop.
Save hannesweisbach/e1a9203e3bc2a00f482309cc5a1bfc73 to your computer and use it in GitHub Desktop.
KiCad macOS install
with import <nixpkgs> {
#with import /Users/hannesweisbach/Software/nixpkgs {
config = {
cores = 6;
packageOverrides = pkgs: {
# see kicad-wxwidgets.nix in the gist below.
wxGTK30 = pkgs.callPackage ~/Software/nix/kicad-wxwidgets.nix {
inherit (pkgs.darwin.stubs) setfile;
inherit (pkgs.darwin.apple_sdk.frameworks) AGL Carbon Cocoa Kernel QTKit WebKit AVFoundation AVKit;
};
};
};
};
let
my-cmake = cmake.overrideAttrs (oldAttrs: {
# let cmake detect libraries located in /usr/lib as system libraries
preConfigure = (oldAttrs.preConfigure or "") + ''
substituteInPlace Modules/GetPrerequisites.cmake --replace \
"if(resolved_file MATCHES \"^(/System/Library/|/var/empty/lib/)\")" \
"if(resolved_file MATCHES \"^(/System/Library/|/usr/lib/)\")"
'';
});
my-kicad = (kicad.override {
pname = "kicad-hannes";
stable = true;
ngspiceSupport = false;
scriptingSupport = false;
oceSupport = false;
cmake = my-cmake;
});
in my-kicad
{ stdenv, fetchgit, fetchurl, pkgconfig
, libXinerama, libSM, libXxf86vm, gtk3, xorgproto, gst_all_1
, libGLSupported ? stdenv.lib.elem stdenv.hostPlatform.system stdenv.lib.platforms.mesaPlatforms
, withMesa ? libGLSupported
, libGLU ? null, libGL ? null
, compat24 ? false, compat26 ? true
, setfile, GL, Carbon, Cocoa, Kernel, QTKit, WebKit, AVFoundation, AVKit
, ...
}:
with stdenv.lib;
assert withMesa -> libGLU != null && libGL != null;
stdenv.mkDerivation {
version = "kicad-3.0.4";
pname = "wxwidgets";
src = fetchgit {
url = "https://gitlab.com/kicad/code/wxWidgets.git";
rev = "53e3765367870187718fc7809f27efc9b40420f8";
# ref = "kicad/macos-wx-3.0";
sha256 = "1yg02d47l4g57bhgn7n09s1k4rjal2mpj89vxiqg1k26zvs7cyc7";
};
buildInputs = [
libXinerama libSM libXxf86vm xorgproto gst_all_1.gstreamer gst_all_1.gst-plugins-base
gtk3 setfile Kernel QTKit WebKit AVFoundation AVKit AGL
]
++ optional withMesa libGLU;
nativeBuildInputs = [ pkgconfig ];
propagatedBuildInputs = [ Carbon Cocoa ];
configureFlags =
[ "--disable-precomp-headers" "--enable-mediactrl"
(if compat24 then "--enable-compat24" else "--disable-compat24")
(if compat26 then "--enable-compat26" else "--disable-compat26")
"--with-cocoa" "--with-macosx-version-min=10.10"
"--enable-webview" "--enable-webview-webkit"
"--enable-unicode"
]
++ optional withMesa "--with-opengl";
SEARCH_LIB = "${libGLU.out}/lib ${libGL.out}/lib ";
preConfigure = ''
substituteInPlace configure --replace 'SEARCH_INCLUDE=' 'DUMMY_SEARCH_INCLUDE='
substituteInPlace configure --replace 'SEARCH_LIB=' 'DUMMY_SEARCH_LIB='
substituteInPlace configure --replace /usr /no-such-path
substituteInPlace configure --replace \
'ac_cv_prog_SETFILE="/Developer/Tools/SetFile"' \
'ac_cv_prog_SETFILE="${setfile}/bin/SetFile"'
substituteInPlace configure --replace "-framework System" -lSystem
'';
postInstall = "
(cd $out/include && ln -s wx-*/* .)
";
passthru = {
inherit compat24 compat26;
unicode = true;
gtk = gtk3;
};
enableParallelBuilding = true;
meta = rec {
description = "wxWidgets pached for KiCad on macOS";
platforms = stdenv.lib.platforms.darwin;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment