anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / applications / science / electronics / fritzing / default.nix
blob04ca24861c0d825b98a14eb824ebdb3054d78f1f
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , wrapQtAppsHook
5 , qmake
6 , pkg-config
7 , qtbase
8 , qtsvg
9 , qttools
10 , qtserialport
11 , qtwayland
12 , qt5compat
13 , boost
14 , libngspice
15 , libgit2
16 , quazip
17 , clipper
20 let
21   # SHA256 of the fritzing-parts HEAD on the master branch,
22   # which contains the latest stable parts definitions
23   partsSha = "015626e6cafb1fc7831c2e536d97ca2275a83d32";
25   parts = fetchFromGitHub {
26     owner = "fritzing";
27     repo = "fritzing-parts";
28     rev = partsSha;
29     hash = "sha256-5jw56cqxpT/8bf1q551WG53J6Lw5pH0HEtRUoNNMc+A=";
30   };
32   # Header-only library
33   svgpp = fetchFromGitHub {
34     owner = "svgpp";
35     repo = "svgpp";
36     rev = "v1.3.0";
37     hash = "sha256-kJEVnMYnDF7bThDB60bGXalYgpn9c5/JCZkRSK5GoE4=";
38   };
41 stdenv.mkDerivation {
42   pname = "fritzing";
43   version = "1.0.2";
45   src = fetchFromGitHub {
46     owner = "fritzing";
47     repo = "fritzing-app";
48     rev = "dbdbe34c843677df721c7b3fc3e32c0f737e7e95";
49     hash = "sha256-Xi5sPU2RGkqh7T+EOvwxJJKKYDhJfccyEZ8LBBTb2s4=";
50   };
52   nativeBuildInputs = [ qmake pkg-config qttools wrapQtAppsHook ];
53   buildInputs = [
54     qtbase
55     qtsvg
56     qtserialport
57     qt5compat
58     boost
59     libgit2
60     quazip
61     libngspice
62     clipper
63   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
64     qtwayland
65   ];
67   postPatch = ''
68     # Use packaged quazip, libgit and ngspice
69     sed -i "/pri\/quazipdetect.pri/d" phoenix.pro
70     sed -i "/pri\/spicedetect.pri/d" phoenix.pro
71     substituteInPlace pri/libgit2detect.pri \
72       --replace-fail 'LIBGIT_STATIC = true' 'LIBGIT_STATIC = false'
74     #TODO: Do not hardcode SHA.
75     substituteInPlace src/fapplication.cpp \
76       --replace-fail 'PartsChecker::getSha(dir.absolutePath());' '"${partsSha}";'
78     substituteInPlace phoenix.pro \
79       --replace-fail "6.5.10" "${qtbase.version}"
81     mkdir parts
82     cp -a ${parts}/* parts/
83   '';
85   env.NIX_CFLAGS_COMPILE = lib.concatStringsSep " " [
86     "-I${lib.getDev quazip}/include/QuaZip-Qt${lib.versions.major qtbase.version}-${quazip.version}"
87     "-I${svgpp}/include"
88     "-I${clipper}/include/polyclipping"
89   ];
90   env.NIX_LDFLAGS = "-lquazip1-qt${lib.versions.major qtbase.version}";
92   qmakeFlags = [
93     "phoenix.pro"
94   ];
96   postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
97     mkdir $out/Applications
98     mv $out/bin/Fritzing.app $out/Applications/Fritzing.app
99     cp FritzingInfo.plist $out/Applications/Fritzing.app/Contents/Info.plist
100     makeWrapper $out/Applications/Fritzing.app/Contents/MacOS/Fritzing $out/bin/Fritzing
101   '';
103   postFixup = ''
104     # generate the parts.db file
105     QT_QPA_PLATFORM=offscreen "$out/bin/Fritzing" \
106       -db "$out/share/fritzing/parts/parts.db" \
107       -pp "$out/share/fritzing/parts" \
108       -folder "$out/share/fritzing"
109   '';
111   meta = with lib; {
112     description = "Open source prototyping tool for Arduino-based projects";
113     homepage = "https://fritzing.org/";
114     license = with licenses; [ gpl3 cc-by-sa-30 ];
115     maintainers = with maintainers; [ robberer muscaln ];
116     platforms = platforms.unix;
117     mainProgram = "Fritzing";
118   };