Something went wrong. Try again.
Sender Policy Framework (RFC 7208) for Zig: the record grammar, the macro language, and an evaluator that takes its resolver from you.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
{ lib, stdenv, callPackage, zig_0_17, # Also run the openspf.org conformance suite in the check phase. Off by # default because it needs the test file, which is a lazy dependency; # nix has already fetched it either way, so this costs nothing here # that it does not cost anywhere else. withConformance ? false,}:let # Generated by zon2nix from build.zig.zon; regenerate with: # nix develop -c zon2nix --17 --nix=build.zig.zon.nix build.zig.zon zigDeps = callPackage ./build.zig.zon.nix { };instdenv.mkDerivation (finalAttrs: { pname = "zig-spf"; # Keep in step with `.version` in build.zig.zon. version = "0.2.0";
# Only what `zig build` actually reads. Narrowing the source this way # keeps a stray .zig-cache out of the store, and means edits to the # flake, the README or the license texts do not invalidate the # derivation. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./src ./tools ]; };
nativeBuildInputs = [ zig_0_17 ];
# All Zig dependencies come from nix, so the sandboxed build never # fetches over the network. zigBuildFlags = [ "--system" "${zigDeps}" ] ++ lib.optionals withConformance [ "-Dconformance=true" ]; # The check phase assembles its own flags rather than reusing the # build's, so without this `zig build test` runs without --system, # tries to fetch, and fails in the sandbox. zigCheckFlags = finalAttrs.zigBuildFlags;
# The tests are hermetic: every one of them reads a table rather than # the network, the conformance suite included, which is what lets it # run inside the sandbox at all. doCheck = true;
meta = { description = "Sender Policy Framework (RFC 7208) for Zig"; longDescription = '' zig-spf implements RFC 7208: the record grammar, the macro language, check_host() with its DNS query budgets, and the Received-SPF header field. The evaluator takes its resolver as a parameter, so a caller can put caching or a table of test data underneath it; a stub resolver over the real DNS is included, as is a small tool that runs a check against it. ''; homepage = "https://git.jcollie.dev/jeff/zig-spf"; license = lib.licenses.mit; mainProgram = "spf"; platforms = lib.platforms.unix; };})