From f9d48637fda09cbe07de11d5cf5284ee6b121549 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Tue, 1 Jul 2025 00:54:01 -0400 Subject: [PATCH] wuffs: init at 0.4.0-alpha.9 --- pkgs/by-name/wu/wuffs/package.nix | 87 +++++++++++++++++++++++++++++++ pkgs/by-name/wu/wuffs/wuffs.pc | 13 +++++ 2 files changed, 100 insertions(+) create mode 100644 pkgs/by-name/wu/wuffs/package.nix create mode 100644 pkgs/by-name/wu/wuffs/wuffs.pc diff --git a/pkgs/by-name/wu/wuffs/package.nix b/pkgs/by-name/wu/wuffs/package.nix new file mode 100644 index 000000000000..b297fac4ac73 --- /dev/null +++ b/pkgs/by-name/wu/wuffs/package.nix @@ -0,0 +1,87 @@ +{ + lib, + stdenv, + fetchFromGitHub, + buildGoModule, + makeBinaryWrapper, + replaceVars, + testers, +}: +let + compiler = + if stdenv.cc.isClang then + "clang" + else if stdenv.cc.isGNU then + "gcc" + else + throw "unsupported compiler"; +in +buildGoModule (finalAttrs: { + pname = "wuffs"; + version = "0.4.0-alpha.9"; + + outputs = [ + "out" + "dev" + "lib" + ]; + + src = fetchFromGitHub { + owner = "google"; + repo = "wuffs"; + tag = "v" + finalAttrs.version; + hash = "sha256-XbupK4QYnPudUlO5tRWrQRncGHITzJL//Yk/E7WNxYk="; + }; + + vendorHash = null; + + strictDeps = true; + nativeBuildInputs = [ makeBinaryWrapper ]; + + subPackages = [ + "cmd/wuffs-c" + "cmd/wuffs" + ]; + + # There are no checks + doCheck = false; + + postInstall = + let + pkgconfig = replaceVars ./wuffs.pc { + LIB = placeholder "lib"; + DEV = placeholder "dev"; + DESCRIPTION = finalAttrs.meta.description; + VERSION = finalAttrs.version; + }; + in + '' + wrapProgram "$out/bin/wuffs" \ + --prefix PATH : "$out/bin" + + "$out/bin/wuffs" gen std/... + "$out/bin/wuffs" genlib -ccompilers=${compiler} + + install -Dm444 -t "$lib/lib" gen/lib/c/${compiler}-dynamic/libwuffs.* + + install -Dm444 release/c/wuffs-unsupported-snapshot.c "$dev/include/wuffs/wuffs-v0.4.c" + + install -Dm444 ${pkgconfig} "$dev/lib/pkgconfig/wuffs.pc" + ''; + + passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + + meta = { + homepage = "https://github.com/google/wuffs"; + description = "memory-safe programming language and standard library for wrangling untrusted data"; + mainProgram = "wuffs"; + pkgConfigModules = [ "wuffs" ]; + license = with lib.licenses; [ + mit + asl20 + ]; + maintainers = with lib.maintainers; [ + RossSmyth + ]; + }; +}) diff --git a/pkgs/by-name/wu/wuffs/wuffs.pc b/pkgs/by-name/wu/wuffs/wuffs.pc new file mode 100644 index 000000000000..bffe9b893687 --- /dev/null +++ b/pkgs/by-name/wu/wuffs/wuffs.pc @@ -0,0 +1,13 @@ +prefix=@LIB@ +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=@DEV@/include/wuffs + +Name: wuffs +Description: @DESCRIPTION@ +Version: @VERSION@ +Requires: +Conflicts: +Libs: -L${libdir} -lwuffs +Libs.private: +Cflags: -I${includedir}