From 9a35a633b122dcbf3ee4634b0f1f0e46f390c501 Mon Sep 17 00:00:00 2001 From: eljamm Date: Fri, 17 Jul 2026 11:00:19 +0200 Subject: [PATCH] zenroom: enable tests --- pkgs/by-name/ze/zenroom/package.nix | 90 +++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 23 deletions(-) diff --git a/pkgs/by-name/ze/zenroom/package.nix b/pkgs/by-name/ze/zenroom/package.nix index d9e43ef9d6c8..ad212d45432a 100644 --- a/pkgs/by-name/ze/zenroom/package.nix +++ b/pkgs/by-name/ze/zenroom/package.nix @@ -14,16 +14,24 @@ # tests callPackage, + jq, + meson, + ninja, }: +let + inherit (stdenv.hostPlatform) + isDarwin + isLinux + isMusl + isUnix + ; +in + stdenv.mkDerivation (finalAttrs: { pname = "zenroom"; version = "5.37.2"; - __structuredAttrs = true; - dontUseCmakeConfigure = true; # cmake is a dependency, but we use make to build - strictDeps = true; - src = fetchFromGitHub { owner = "dyne"; repo = "Zenroom"; @@ -38,9 +46,22 @@ stdenv.mkDerivation (finalAttrs: { }; postPatch = '' - patchShebangs build/embed-lualibs + patchShebangs build/{embed-lualibs,meson_version.sh} + patchShebangs test/ ''; + __structuredAttrs = true; + strictDeps = true; + + # cmake is required to build dependencies, not the main package + dontUseCmakeConfigure = true; + + # manually invoken while testing + dontUseMesonConfigure = true; + dontUseNinjaBuild = true; + dontUseNinjaCheck = true; + dontUseNinjaInstall = true; + nativeBuildInputs = [ cmake which # ar @@ -51,23 +72,27 @@ stdenv.mkDerivation (finalAttrs: { readline ]; - buildFlags = - with stdenv.hostPlatform; - lib.optionals (isLinux && !isMusl) [ - "linux-lib" - "linux-exe" - ] - ++ lib.optionals (isLinux && isMusl) [ - "musl" - ] - ++ lib.optionals isDarwin [ - "osx-lib" - "osx-exe" - ] - ++ lib.optionals (isUnix && !isLinux && !isDarwin) [ - "posix-lib" - "posix-exe" - ]; + buildFlags = [ + "VERSION=${finalAttrs.version}" + "COMMIT=0000000" + "BRANCH=master" + "CURRENT_YEAR=1970" # unix epoch + ] + ++ lib.optionals (isLinux && !isMusl) [ + "linux-lib" + "linux-exe" + ] + ++ lib.optionals (isLinux && isMusl) [ + "musl" + ] + ++ lib.optionals isDarwin [ + "osx-lib" + "osx-exe" + ] + ++ lib.optionals (isUnix && !isLinux && !isDarwin) [ + "posix-lib" + "posix-exe" + ]; hardeningDisable = [ "format" ]; # -Werror=format-security @@ -82,11 +107,30 @@ stdenv.mkDerivation (finalAttrs: { install -D libzenroom${stdenv.hostPlatform.extensions.sharedLibrary} -t $out/lib ''; + nativeCheckInputs = [ + jq + meson + ninja + ]; + + doCheck = true; + checkTarget = "check" + lib.optionalString isDarwin "-osx"; + + preCheck = + lib.optionalString isDarwin # sh + '' + # on darwin, we're using GNU base64 + substituteInPlace test/zencode/cookbook_{hash_pdf,ecdh_encrypt_json}.bats \ + --replace-fail \ + 'cmd_base64="base64 -b 0"' \ + 'cmd_base64="base64 -w 0"' + ''; + passthru.updateScript = nix-update-script { }; passthru.tests = callPackage ./tests { zenroom = finalAttrs.finalPackage; }; meta = { - description = "no-code cryptographic virtual machine"; + description = "No-code cryptographic virtual machine"; longDescription = '' Zenroom is a tiny, portable, and fully isolated crypto VM for building privacy-preserving applications, smart contracts, and secure data