1 { lib, stdenv, fetchFromGitHub, fetchpatch2, SDL_gfx, SDL, libjpeg, libpng
2 , opencv, pkg-config }:
4 stdenv.mkDerivation (finalAttrs: {
8 src = fetchFromGitHub {
11 rev = "v${finalAttrs.version}";
12 hash = "sha256-zdq/YKL33jJXa10RqmQIl06rRYnrthWG+umT4dipft0=";
16 # don't try to change ownership
17 substituteInPlace Makefile \
18 --replace-fail "-o root" "" \
19 --replace-fail "-g root" ""
22 nativeBuildInputs = [ pkg-config ];
23 buildInputs = [ SDL SDL_gfx libjpeg libpng opencv ];
25 makeFlags = [ "PREFIX=$(out)" ];
26 env.NIX_CFLAGS_COMPILE = "-I${lib.getDev SDL}/include/SDL -I${SDL_gfx}/include/SDL";
30 url = "https://github.com/dlbeer/quirc/commit/2c350d8aaf37246e538a2c93b2cce8c78600d2fc.patch?full_index=1";
31 hash = "sha256-ZTcy/EoOBoyOjtXjmT+J/JcbX8lxGKmbWer23lymbWo=";
34 url = "https://github.com/dlbeer/quirc/commit/257c6c94d99960819ecabf72199e5822f60a3bc5.patch?full_index=1";
35 hash = "sha256-WLQK7vy34VmgJzppTnRjAcZoSGWVaXQSaGq9An8W0rw=";
37 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
38 # Disable building of linux-only demos on darwin systems
39 ./0001-Don-t-build-demos.patch
43 mkdir -p "$out"/{bin,lib,include}
45 # install all binaries
46 find -maxdepth 1 -type f -executable ! -name '*.so.*' ! -name '*.dylib' \
47 | xargs cp -t "$out"/bin
51 # don't install static library
52 rm $out/lib/libquirc.a
53 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
54 # Set absolute install name to avoid the need for DYLD_LIBRARY_PATH
55 dylib=$out/lib/libquirc.${finalAttrs.version}.dylib
56 ${stdenv.cc.targetPrefix}install_name_tool -id "$dylib" "$dylib"
60 description = "Small QR code decoding library";
61 license = lib.licenses.isc;
62 maintainers = [ lib.maintainers.raskin ];
63 platforms = lib.platforms.linux ++ [ "x86_64-darwin" "aarch64-darwin" ];