summaryrefslogtreecommitdiffstats
path: root/pkgs/development/libraries/qzxing/default.nix
blob: 980047a5a6dd672ff85f6ce5997f76cda18141d1 (plain)
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
{
  stdenv,
  lib,
  fetchFromGitHub,
  gitUpdater,
  testers,
  qmake,
  qtmultimedia,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "qzxing";
  version = "3.3.0";

  src = fetchFromGitHub {
    owner = "ftylitak";
    repo = "qzxing";
    rev = "v${finalAttrs.version}";
    hash = "sha256-ASgsF5ocNWAiIy2jm6ygpDkggBcEpno6iVNWYkuWcVI=";
  };

  # greaterThan/lessThan don't handle versions, use versionAtLeast/versionAtMost instead
  # Versions are different due to versionAtLeast/-Most using an inclusive limit, while greater-/lessThan use exclusive ones
  postPatch = ''
    substituteInPlace src/QZXing-components.pri \
      --replace-fail 'lessThan(QT_VERSION, 6.2)' 'versionAtMost(QT_VERSION, 6.1)' \
      --replace-fail 'greaterThan(QT_VERSION, 6.1)' 'versionAtLeast(QT_VERSION, 6.2)'
  '';

  # QMake can't find qtmultimedia in buildInputs
  strictDeps = false;

  nativeBuildInputs = [
    qmake
  ];

  buildInputs = [
    qtmultimedia
  ];

  dontWrapQtApps = true;

  preConfigure = ''
    cd src
  '';

  qmakeFlags = [
    "CONFIG+=qzxing_qml"
    "CONFIG+=qzxing_multimedia"
    "QMAKE_PKGCONFIG_PREFIX=${placeholder "out"}"
  ];

  passthru = {
    tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
    updateScript = gitUpdater {
      rev-prefix = "v";
    };
  };

  meta = {
    description = "Qt/QML wrapper library for the ZXing library";
    homepage = "https://github.com/ftylitak/qzxing";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ OPNA2608 ];
    platforms = lib.platforms.unix;
    pkgConfigModules = [
      "QZXing"
    ];
  };
})