winePackages.{staging,unstable}: 9.22 -> 10.0-rc4 (#368663)
[NixPkgs.git] / pkgs / applications / science / electronics / fritzing / default.nix
blobf0d98e7a823c111a0e189bf4c55bd06fd27c49d9
2   stdenv,
3   lib,
4   fetchFromGitHub,
5   wrapQtAppsHook,
6   qmake,
7   pkg-config,
8   qtbase,
9   qtsvg,
10   qttools,
11   qtserialport,
12   qtwayland,
13   qt5compat,
14   boost,
15   libngspice,
16   libgit2,
17   quazip,
18   clipper,
21 let
22   # SHA256 of the fritzing-parts HEAD on the master branch,
23   # which contains the latest stable parts definitions
24   partsSha = "76235099ed556e52003de63522fdd74e61d53a36";
26   parts = fetchFromGitHub {
27     owner = "fritzing";
28     repo = "fritzing-parts";
29     rev = partsSha;
30     hash = "sha256-1QVcPbRBOSYnNFsp7B2OyPXYuPaINRv9yEqGZFd662Y=";
31   };
33   # Header-only library
34   svgpp = fetchFromGitHub {
35     owner = "svgpp";
36     repo = "svgpp";
37     tag = "v1.3.1";
38     hash = "sha256-nW0ns06XWfUi22nOKZzFKgAOHVIlQqChW8HxUDOFMh4=";
39   };
42 stdenv.mkDerivation {
43   pname = "fritzing";
44   version = "1.0.4";
46   src = fetchFromGitHub {
47     owner = "fritzing";
48     repo = "fritzing-app";
49     rev = "a8c6ef7cf66f7a42b9b233d6137f1b70a9573a25";
50     hash = "sha256-a/bWAUeDPj3g8BECOlXuqyCi4JgGLLs1605m380Drt0=";
51   };
53   nativeBuildInputs = [
54     qmake
55     pkg-config
56     qttools
57     wrapQtAppsHook
58   ];
60   buildInputs =
61     [
62       qtbase
63       qtsvg
64       qtserialport
65       qt5compat
66       boost
67       libgit2
68       quazip
69       libngspice
70       clipper
71     ]
72     ++ lib.optionals stdenv.hostPlatform.isLinux [
73       qtwayland
74     ];
76   postPatch = ''
77     # Use packaged quazip, libgit and ngspice
78     sed -i "/pri\/quazipdetect.pri/d" phoenix.pro
79     sed -i "/pri\/spicedetect.pri/d" phoenix.pro
80     substituteInPlace pri/libgit2detect.pri \
81       --replace-fail 'LIBGIT_STATIC = true' 'LIBGIT_STATIC = false'
83     #TODO: Do not hardcode SHA.
84     substituteInPlace src/fapplication.cpp \
85       --replace-fail 'PartsChecker::getSha(dir.absolutePath());' '"${partsSha}";'
87     substituteInPlace phoenix.pro \
88       --replace-fail "6.5.10" "${qtbase.version}"
90     mkdir parts
91     cp -a ${parts}/* parts/
92   '';
94   env = {
95     NIX_CFLAGS_COMPILE = lib.concatStringsSep " " [
96       "-I${lib.getDev quazip}/include/QuaZip-Qt${lib.versions.major qtbase.version}-${quazip.version}"
97       "-I${svgpp}/include"
98       "-I${clipper}/include/polyclipping"
99     ];
100     NIX_LDFLAGS = "-lquazip1-qt${lib.versions.major qtbase.version}";
101   };
103   qmakeFlags = [
104     "phoenix.pro"
105   ];
107   postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
108     mkdir $out/Applications
109     mv $out/bin/Fritzing.app $out/Applications/Fritzing.app
110     cp FritzingInfo.plist $out/Applications/Fritzing.app/Contents/Info.plist
111     makeWrapper $out/Applications/Fritzing.app/Contents/MacOS/Fritzing $out/bin/Fritzing
112   '';
114   postFixup = ''
115     # generate the parts.db file
116     QT_QPA_PLATFORM=offscreen "$out/bin/Fritzing" \
117       -db "$out/share/fritzing/parts/parts.db" \
118       -pp "$out/share/fritzing/parts" \
119       -folder "$out/share/fritzing"
120   '';
122   meta = {
123     description = "Open source prototyping tool for Arduino-based projects";
124     homepage = "https://fritzing.org";
125     license = with lib.licenses; [
126       gpl3
127       cc-by-sa-30
128     ];
129     maintainers = with lib.maintainers; [
130       robberer
131       muscaln
132     ];
133     platforms = lib.platforms.unix;
134     mainProgram = "Fritzing";
135   };