An SMTP client and server library for Zig implementing RFC 5321.
0

Configure Feed

Select the types of activity you want to include in your feed.

Model package.nix after vaultz

The package moves to the repo root and adopts the vaultz style:
finalAttrs, a fileset-narrowed src (build.zig, build.zig.zon, src - so
flake or docs edits no longer invalidate the derivation), the nixpkgs
zig setup hook for the standard phases (yielding a portable
-Dcpu=baseline --release=safe binary instead of hand-rolled build and
check phases), zigBuildFlags/zigCheckFlags carrying --system with the
zon2nix-generated dependencies, and full meta with longDescription,
homepage, mainProgram, and platforms.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012HBHFhoTYa8TU9GLwobfbx

+69 -49
+2 -2
flake.nix
··· 34 34 pkgs = makePackages system; 35 35 in 36 36 rec { 37 - zsmtp = pkgs.callPackage ./nix/package.nix { }; 37 + zsmtp = pkgs.callPackage ./package.nix { }; 38 38 default = zsmtp; 39 39 zig-deps = pkgs.callPackage ./build.zig.zon.nix { }; 40 40 } ··· 46 46 pkgs = makePackages system; 47 47 in 48 48 { 49 - zsmtp = pkgs.callPackage ./nix/package.nix { }; 49 + zsmtp = pkgs.callPackage ./package.nix { }; 50 50 interop = pkgs.callPackage ./nix/interop-test.nix { }; 51 51 } 52 52 );
+66
package.nix
··· 1 + # SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us> 2 + # SPDX-License-Identifier: MIT 3 + 4 + { 5 + lib, 6 + stdenv, 7 + callPackage, 8 + zig_0_16, 9 + }: 10 + let 11 + # Generated by zon2nix from build.zig.zon; regenerate with: 12 + # nix run github:jcollie/zon2nix#zon2nix -- --nix=build.zig.zon.nix --16 build.zig.zon 13 + zigDeps = callPackage ./build.zig.zon.nix { }; 14 + in 15 + stdenv.mkDerivation (finalAttrs: { 16 + pname = "zsmtp"; 17 + # Keep in step with `.version` in build.zig.zon. 18 + version = "0.0.0"; 19 + 20 + # Only what `zig build` actually reads. Narrowing the source this way keeps 21 + # a stray .zig-cache out of the store, and means edits to the flake, the 22 + # README or the license texts do not invalidate the derivation. 23 + src = lib.fileset.toSource { 24 + root = ./.; 25 + fileset = lib.fileset.unions [ 26 + ./build.zig 27 + ./build.zig.zon 28 + ./src 29 + ]; 30 + }; 31 + 32 + # Provides the configure/build/check/install phases for a `zig build` 33 + # project, including a writable ZIG_GLOBAL_CACHE_DIR. It passes 34 + # `-Dcpu=baseline --release=safe`, so the result is a portable ReleaseSafe 35 + # binary rather than the Debug one `zig build` produces by default. 36 + nativeBuildInputs = [ zig_0_16 ]; 37 + 38 + # All Zig dependencies come from nix, so the sandboxed build never 39 + # fetches over the network. 40 + zigBuildFlags = [ 41 + "--system" 42 + "${zigDeps}" 43 + ]; 44 + zigCheckFlags = finalAttrs.zigBuildFlags; 45 + 46 + # `zig build test` is fully hermetic: scripted sessions over in-memory 47 + # readers and writers. Interoperability against real MTAs is covered by 48 + # the NixOS VM check instead. 49 + doCheck = true; 50 + 51 + meta = { 52 + description = "SMTP client and server library for Zig"; 53 + longDescription = '' 54 + zsmtp is an SMTP client and server library (RFC 5321) for Zig. Both 55 + sides run over plain std.Io.Reader/std.Io.Writer pairs, making them 56 + transport-agnostic, and support STARTTLS and implicit TLS, AUTH, 57 + streamed message bodies, and the SIZE, 8BITMIME, CHUNKING and 58 + SMTPUTF8 extensions. A small demo CLI for sending and receiving is 59 + included. 60 + ''; 61 + homepage = "https://git.ocjtech.us/jeff/zsmtp"; 62 + license = lib.licenses.mit; 63 + mainProgram = "zsmtp"; 64 + platforms = lib.platforms.unix; 65 + }; 66 + })
+1 -1
nix/interop-test.nix
··· 15 15 openssl, 16 16 }: 17 17 let 18 - zsmtp = callPackage ./package.nix { }; 18 + zsmtp = callPackage ../package.nix { }; 19 19 20 20 snakeoil = 21 21 runCommand "zsmtp-test-cert"
-46
nix/package.nix
··· 1 - # SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us> 2 - # SPDX-License-Identifier: MIT 3 - 4 - { 5 - lib, 6 - stdenv, 7 - callPackage, 8 - zig_0_16, 9 - }: 10 - let 11 - # Generated by zon2nix from build.zig.zon; regenerate with: 12 - # nix run github:jcollie/zon2nix#zon2nix -- --nix=build.zig.zon.nix --16 build.zig.zon 13 - zigDeps = callPackage ../build.zig.zon.nix { }; 14 - in 15 - stdenv.mkDerivation { 16 - pname = "zsmtp"; 17 - version = "0.0.0"; 18 - 19 - src = lib.cleanSource ../.; 20 - 21 - nativeBuildInputs = [ zig_0_16 ]; 22 - 23 - dontConfigure = true; 24 - 25 - buildPhase = '' 26 - runHook preBuild 27 - export ZIG_GLOBAL_CACHE_DIR=$TMPDIR/zig-global-cache 28 - zig build install -Doptimize=ReleaseSafe --prefix $out --system ${zigDeps} 29 - runHook postBuild 30 - ''; 31 - 32 - doCheck = true; 33 - checkPhase = '' 34 - runHook preCheck 35 - zig build test --system ${zigDeps} 36 - runHook postCheck 37 - ''; 38 - 39 - dontInstall = true; 40 - 41 - meta = { 42 - description = "SMTP client and server library for Zig"; 43 - license = lib.licenses.mit; 44 - mainProgram = "zsmtp"; 45 - }; 46 - }