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