1{
2 stdenv,
3 fetchFromGitHub,
4 lib,
5 subproject ? "library", # one of "library", "reader" or "writer"
6 zlib,
7 libpng,
8 libtiff,
9 jabcode,
10}:
11let
12 subdir = lib.getAttr subproject {
13 "library" = "jabcode";
14 "reader" = "jabcodeReader";
15 "writer" = "jabcodeWriter";
16 };
17in
18stdenv.mkDerivation rec {
19 pname = "jabcode-${subproject}";
20 version = "unstable-2022-06-17";
21 src = fetchFromGitHub {
22 repo = "jabcode";
23 owner = "jabcode";
24 rev = "ee0e4c88b9f3c1da46d6f679ee8b69c547907c20";
25 hash = "sha256-GjRkDWefQFdT4i9hRcQhYsY4beMUIXxy38I5lsQytyA=";
26 };
27
28 nativeBuildInputs = [
29 zlib
30 libpng
31 libtiff
32 ] ++ lib.optionals (subproject != "library") [ jabcode ];
33
34 preConfigure = "cd src/${subdir}";
35
36 installPhase =
37 if subproject == "library" then
38 ''
39 mkdir -p $out/lib
40 cp build/* $out/lib
41 ''
42 else
43 ''
44 mkdir -p $out/bin
45 cp -RT bin $out/bin
46 '';
47
48 meta = with lib; {
49 description = "High-capacity 2D color bar code (${subproject})";
50 longDescription = "JAB Code (Just Another Bar Code) is a high-capacity 2D color bar code, which can encode more data than traditional black/white (QR) codes. This is the ${subproject} part.";
51 homepage = "https://jabcode.org/";
52 license = licenses.lgpl21;
53 maintainers = [ maintainers.xaverdh ];
54 platforms = platforms.unix;
55 broken = stdenv.hostPlatform.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/jabcode.x86_64-darwin
56 };
57}