2022-04-15 01:41:22 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, SDL_gfx, SDL, libjpeg, libpng, opencv
|
|
|
|
, pkg-config }:
|
2021-05-03 20:48:10 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2021-05-03 20:48:10 +00:00
|
|
|
pname = "quirc";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "1.2";
|
2021-05-03 20:48:10 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "dlbeer";
|
|
|
|
repo = "quirc";
|
2024-04-21 15:54:59 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
hash = "sha256-zdq/YKL33jJXa10RqmQIl06rRYnrthWG+umT4dipft0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2021-05-03 20:48:10 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
postPatch = ''
|
|
|
|
# don't try to change ownership
|
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace-fail "-o root" "" \
|
|
|
|
--replace-fail "-g root" ""
|
|
|
|
'';
|
|
|
|
|
2021-05-03 20:48:10 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2022-04-15 01:41:22 +00:00
|
|
|
buildInputs = [ SDL SDL_gfx libjpeg libpng opencv ];
|
2021-05-03 20:48:10 +00:00
|
|
|
|
|
|
|
makeFlags = [ "PREFIX=$(out)" ];
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = "-I${lib.getDev SDL}/include/SDL -I${SDL_gfx}/include/SDL";
|
2021-05-03 20:48:10 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Disable building of linux-only demos on darwin systems
|
|
|
|
patches = lib.optionals stdenv.isDarwin [ ./0001-dont-build-demos.patch ];
|
|
|
|
|
|
|
|
buildPhase = lib.optionalString stdenv.isDarwin ''
|
|
|
|
runHook preBuild
|
|
|
|
make libquirc.so
|
|
|
|
make qrtest
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preInstall = ''
|
|
|
|
mkdir -p "$out"/{bin,lib,include}
|
2021-05-03 20:48:10 +00:00
|
|
|
|
|
|
|
# install all binaries
|
|
|
|
find -maxdepth 1 -type f -executable ! -name '*.so.*' | xargs cp -t "$out"/bin
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2021-05-03 20:48:10 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
postInstall = ''
|
|
|
|
# don't install static library
|
|
|
|
rm $out/lib/libquirc.a
|
|
|
|
|
|
|
|
ln -s $out/lib/libquirc.so.* $out/lib/libquirc.so
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = {
|
2021-02-05 17:12:51 +00:00
|
|
|
description = "A small QR code decoding library";
|
2021-01-15 22:18:51 +00:00
|
|
|
license = lib.licenses.isc;
|
2022-04-15 01:41:22 +00:00
|
|
|
maintainers = [ lib.maintainers.raskin ];
|
|
|
|
platforms = lib.platforms.linux ++ [ "x86_64-darwin" "aarch64-darwin" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
})
|