nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch2,
6 libjpeg,
7 libpng,
8}:
9
10stdenv.mkDerivation (finalAttrs: {
11 pname = "quirc";
12 version = "1.2";
13
14 src = fetchFromGitHub {
15 owner = "dlbeer";
16 repo = "quirc";
17 rev = "v${finalAttrs.version}";
18 hash = "sha256-zdq/YKL33jJXa10RqmQIl06rRYnrthWG+umT4dipft0=";
19 };
20
21 postPatch = ''
22 # use correct pkg-config / ar / ranlib for cross
23 # don't try to change ownership
24 substituteInPlace Makefile \
25 --replace-fail "ar " "${stdenv.cc.targetPrefix}ar " \
26 --replace-fail "ranlib " "${stdenv.cc.targetPrefix}ranlib " \
27 --replace-fail "-o root" "" \
28 --replace-fail "-g root" ""
29 '';
30
31 buildInputs = [
32 libjpeg
33 libpng
34 ];
35
36 makeFlags = [
37 "PREFIX=$(out)"
38 "SDL_CFLAGS="
39 "SDL_LIBS="
40 "-o inspect"
41 "-o quirc-demo"
42 ];
43
44 patches = [
45 (fetchpatch2 {
46 url = "https://github.com/dlbeer/quirc/commit/2c350d8aaf37246e538a2c93b2cce8c78600d2fc.patch?full_index=1";
47 hash = "sha256-ZTcy/EoOBoyOjtXjmT+J/JcbX8lxGKmbWer23lymbWo=";
48 })
49 (fetchpatch2 {
50 url = "https://github.com/dlbeer/quirc/commit/257c6c94d99960819ecabf72199e5822f60a3bc5.patch?full_index=1";
51 hash = "sha256-WLQK7vy34VmgJzppTnRjAcZoSGWVaXQSaGq9An8W0rw=";
52 })
53 # Disable building of Demos to not pull in unwanted dependencies
54 ./0001-Don-t-build-demos.patch
55 ];
56
57 preInstall = ''
58 mkdir -p "$out"/{bin,lib,include}
59
60 # install all binaries
61 find -maxdepth 1 -type f -executable ! -name '*.so.*' ! -name '*.dylib' \
62 | xargs cp -t "$out"/bin
63 '';
64
65 postInstall = ''
66 # don't install static library
67 rm $out/lib/libquirc.a
68 ''
69 + lib.optionalString stdenv.hostPlatform.isDarwin ''
70 # Set absolute install name to avoid the need for DYLD_LIBRARY_PATH
71 dylib=$out/lib/libquirc.${finalAttrs.version}.dylib
72 ${stdenv.cc.targetPrefix}install_name_tool -id "$dylib" "$dylib"
73 '';
74
75 meta = {
76 description = "Small QR code decoding library";
77 license = lib.licenses.isc;
78 maintainers = [ lib.maintainers.raskin ];
79 platforms = lib.platforms.unix;
80 };
81})