nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 kdePackages,
6 pkg-config,
7 qt6,
8 boost,
9 libngspice,
10 libgit2,
11 clipper,
12}:
13
14let
15 # SHA256 of the fritzing-parts HEAD on the develop branch,
16 # which contains the latest stable parts definitions
17 partsSha = "73bc0559bb8399b2f895d68f032e41d7efc720c0";
18
19 parts = fetchFromGitHub {
20 owner = "fritzing";
21 repo = "fritzing-parts";
22 rev = partsSha;
23 hash = "sha256-2aXvSXWjQliEChQGhcCicOVoAqeNdeq69wQVYQsd2ew=";
24 };
25
26 # Header-only library
27 svgpp = fetchFromGitHub {
28 owner = "svgpp";
29 repo = "svgpp";
30 tag = "v1.3.1";
31 hash = "sha256-nW0ns06XWfUi22nOKZzFKgAOHVIlQqChW8HxUDOFMh4=";
32 };
33in
34
35stdenv.mkDerivation {
36 pname = "fritzing";
37 version = "1.0.6";
38
39 src = fetchFromGitHub {
40 owner = "fritzing";
41 repo = "fritzing-app";
42 rev = "04e5bb0241e8f1de24d0fce9be070041c6d5b68e";
43 hash = "sha256-JlqBdzWscJoD859KMYgT/af41WNWThP65K3zh2PC2jM=";
44 };
45
46 patches = [
47 # Fix build with Qt >= 6.9
48 ./fix-stricter-types.patch
49 ];
50
51 nativeBuildInputs = [
52 kdePackages.qmake
53 pkg-config
54 qt6.qttools
55 kdePackages.wrapQtAppsHook
56 ];
57
58 buildInputs = [
59 qt6.qtbase
60 qt6.qtsvg
61 qt6.qtserialport
62 kdePackages.qt5compat
63 boost
64 libgit2
65 kdePackages.quazip
66 libngspice
67 clipper
68 ]
69 ++ lib.optionals stdenv.hostPlatform.isLinux [
70 qt6.qtwayland
71 ];
72
73 postPatch = ''
74 # Use packaged quazip, libgit and ngspice
75 sed -i "/pri\/quazipdetect.pri/d" phoenix.pro
76 sed -i "/pri\/spicedetect.pri/d" phoenix.pro
77 substituteInPlace pri/libgit2detect.pri \
78 --replace-fail 'LIBGIT_STATIC = true' 'LIBGIT_STATIC = false'
79
80 #TODO: Do not hardcode SHA.
81 substituteInPlace src/fapplication.cpp \
82 --replace-fail 'PartsChecker::getSha(dir.absolutePath());' '"${partsSha}";'
83
84 substituteInPlace phoenix.pro \
85 --replace-fail "6.5.10" "${qt6.qtbase.version}"
86
87 substituteInPlace src/simulation/ngspice_simulator.cpp \
88 --replace-fail 'path + "/" + libName' '"${libngspice}/lib/libngspice.so"'
89
90 mkdir parts
91 cp -a ${parts}/* parts/
92 '';
93
94 env = {
95 NIX_CFLAGS_COMPILE = lib.concatStringsSep " " (
96 [
97 "-I${lib.getDev kdePackages.quazip}/include/QuaZip-Qt${lib.versions.major qt6.qtbase.version}-${kdePackages.quazip.version}"
98 "-I${svgpp}/include"
99 "-I${clipper}/include/polyclipping"
100 ]
101 ++ lib.optionals stdenv.hostPlatform.isDarwin [ "-F${kdePackages.qt5compat}/lib" ]
102 );
103 NIX_LDFLAGS = "-lquazip1-qt${lib.versions.major qt6.qtbase.version}";
104 };
105
106 qmakeFlags = [
107 "phoenix.pro"
108 ];
109
110 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
111 mkdir $out/Applications
112 mv $out/bin/Fritzing.app $out/Applications/Fritzing.app
113 cp FritzingInfo.plist $out/Applications/Fritzing.app/Contents/Info.plist
114 makeWrapper $out/Applications/Fritzing.app/Contents/MacOS/Fritzing $out/bin/Fritzing
115 '';
116
117 postFixup = ''
118 # generate the parts.db file
119 QT_QPA_PLATFORM=offscreen "$out/bin/Fritzing" \
120 -db "$out/share/fritzing/parts/parts.db" \
121 -pp "$out/share/fritzing/parts" \
122 -folder "$out/share/fritzing"
123 '';
124
125 meta = {
126 description = "Open source prototyping tool for Arduino-based projects";
127 homepage = "https://fritzing.org";
128 license = with lib.licenses; [
129 gpl3
130 cc-by-sa-30
131 ];
132 maintainers = with lib.maintainers; [
133 robberer
134 muscaln
135 ];
136 platforms = lib.platforms.unix;
137 mainProgram = "Fritzing";
138 };
139}