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