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-2020-05-13";
20 src = fetchFromGitHub {
21 repo = "jabcode";
22 owner = "jabcode";
23 rev = "a7c25d4f248078f257b014e31c791bfcfcd083e1";
24 sha256 = "1c4cv9b0d7r4bxzkwzdv9h651ziq822iya6fbyizm57n1nzdkk4s";
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 };
50}