From 0164461684445b87208aa73cf3f456e55e8cb832 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 30 Jul 2023 17:19:20 -0300 Subject: [PATCH] qrcodegen: refactor - Use rec-less, overlay-style overridable recursive attributes (in effect since https://github.com/NixOS/nixpkgs/pull/119942) - Add checkPhase --- .../libraries/qrcodegen/default.nix | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/pkgs/development/libraries/qrcodegen/default.nix b/pkgs/development/libraries/qrcodegen/default.nix index eeb830d3fec48..e5c4f036ffc3f 100644 --- a/pkgs/development/libraries/qrcodegen/default.nix +++ b/pkgs/development/libraries/qrcodegen/default.nix @@ -3,18 +3,20 @@ , fetchFromGitHub }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "qrcodegen"; version = "1.8.0"; src = fetchFromGitHub { owner = "nayuki"; repo = "QR-Code-generator"; - rev = "v${version}"; - sha256 = "sha256-aci5SFBRNRrSub4XVJ2luHNZ2pAUegjgQ6pD9kpkaTY="; + rev = "v${finalAttrs.version}"; + hash = "sha256-aci5SFBRNRrSub4XVJ2luHNZ2pAUegjgQ6pD9kpkaTY="; }; - sourceRoot = "source/c"; + preBuild = '' + cd c + ''; nativeBuildInputs = lib.optionals stdenv.cc.isClang [ stdenv.cc.cc.libllvm.out @@ -22,23 +24,31 @@ stdenv.mkDerivation rec { makeFlags = lib.optionals stdenv.cc.isClang [ "AR=llvm-ar" ]; + doCheck = true; + checkPhase = '' + runHook preCheck + + ./qrcodegen-test + + runHook postCheck + ''; + installPhase = '' runHook preInstall - mkdir -p $out/lib $out/include/qrcodegen - cp libqrcodegen.a $out/lib - cp qrcodegen.h $out/include/qrcodegen/ + install -Dt $out/lib/ libqrcodegen.a + install -Dt $out/include/qrcodegen/ qrcodegen.h runHook postInstall ''; - meta = with lib; { + meta = { homepage = "https://www.nayuki.io/page/qr-code-generator-library"; description = "High-quality QR Code generator library in many languages"; - license = licenses.mit; - maintainers = with maintainers; [ mcbeth AndersonTorres ]; - platforms = platforms.unix; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ AndersonTorres ]; + platforms = lib.platforms.unix; }; -} +}) # TODO: build the other languages # TODO: multiple outputs