about summary refs log tree commit diff
path: root/pkgs/applications/science/electronics/fritzing/default.nix
blob: 668a34b511d49a3dbaf88669d4daaad907acec08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{ mkDerivation
, lib
, fetchFromGitHub
, fetchpatch
, qmake
, pkg-config
, qtbase
, qtsvg
, qttools
, qtserialport
, boost
, libgit2
, quazip
}:

let
  # SHA256 of the fritzing-parts HEAD on the master branch,
  # which contains the latest stable parts definitions
  partsSha = "640fa25650211afccd369f960375ade8ec3e8653";

  parts = fetchFromGitHub {
    owner = "fritzing";
    repo = "fritzing-parts";
    rev = partsSha;
    sha256 = "sha256-4S65eX4LCnXCFQAOxmdvr8d0nAgTWcJooE2SpLYpcXI=";
  };
in

mkDerivation rec {
  pname = "fritzing";
  version = "unstable-2021-09-22";

  src = fetchFromGitHub {
    owner = pname;
    repo = "fritzing-app";
    rev = "f0af53a9077f7cdecef31d231b85d8307de415d4";
    sha256 = "sha256-fF38DrBoeZ0aKwVMNyYMPWa5rFPbIVXRARZT+eRat5Q=";
  };

  buildInputs = [ qtbase qtsvg qtserialport boost libgit2 quazip ];
  nativeBuildInputs = [ qmake pkg-config qttools ];

  patches = [
    # Add support for QuaZip 1.x
    (fetchpatch {
      url = "https://github.com/fritzing/fritzing-app/commit/ef83ebd9113266bb31b3604e3e9d0332bb48c999.patch";
      sha256 = "sha256-J43E6iBRIVbsuuo82gPk3Q7tyLhNkuuyYwtH8hUfcPU=";
    })
  ];

  postPatch = ''
    substituteInPlace phoenix.pro \
      --replace 'LIBGIT_STATIC = true' 'LIBGIT_STATIC = false'

    #TODO: Do not hardcode SHA.
    substituteInPlace src/fapplication.cpp \
      --replace 'PartsChecker::getSha(dir.absolutePath());' '"${partsSha}";'

    mkdir parts
    cp -a ${parts}/* parts/
  '';

  qmakeFlags = [
    "phoenix.pro"
    "DEFINES=QUAZIP_INSTALLED"
    "DEFINES+=QUAZIP_1X"
  ];

  postFixup = ''
    # generate the parts.db file
    QT_QPA_PLATFORM=offscreen "$out/bin/Fritzing" \
      -db "$out/share/fritzing/parts/parts.db" \
      -pp "$out/share/fritzing/parts" \
      -folder "$out/share/fritzing"
  '';

  meta = with lib; {
    description = "An open source prototyping tool for Arduino-based projects";
    homepage = "https://fritzing.org/";
    license = with licenses; [ gpl3 cc-by-sa-30 ];
    maintainers = with maintainers; [ robberer muscaln ];
    platforms = platforms.linux;
  };
}