# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT { lib, stdenv, zig_0_17, }: stdenv.mkDerivation { pname = "zig-riff"; # Taken from build.zig.zon so that the package version cannot drift from the # one the Zig package manager reports. version = let zon = builtins.readFile ./build.zig.zon; matched = builtins.match ''.*\.version = "([^"]+)".*'' zon; in if matched == null then throw "zig-riff: no .version found in build.zig.zon" else builtins.head matched; # Named rather than filtered, so that editing something outside this list -- # the flake, a scratch file, the README -- does not rebuild the package. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./src ./tools ./LICENSES ./README.md ./REUSE.toml ]; }; nativeBuildInputs = [ zig_0_17.hook ]; # No dependencies at all, so there is no package cache to hand in and no # build.zig.zon.nix to generate: this library is `std` and nothing else. doCheck = true; meta = { description = "A sans-I/O reader and writer for the RIFF container format"; longDescription = '' RIFF is the container underneath WAV, AVI, WebP and a good deal else: a twelve-byte header naming a form type, and then chunks of a four-character identifier and a length. This reads and writes it through a caller-supplied `std.Io.Reader` and `std.Io.Writer`, handling the even-length padding, `LIST` nesting and the big-endian `RIFX` variant, and refusing RF64 by name rather than as a corrupt file. ''; homepage = "https://git.jcollie.dev/jeff/zig-riff"; license = lib.licenses.mit; platforms = lib.platforms.all; }; }