# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT { lib, stdenv, zig_0_16, fetchzip, }: let # Must match the url/hash pinned in build.zig.zon. Only the files listed in # the dependency's `paths` may end up in zig-pkg/, since Zig hashes the # package contents against the directory name. tlsDep = fetchzip { name = "tls.zig-src"; url = "https://github.com/ianic/tls.zig/archive/e04ae448ce7ee70c136d4d48b059314543203809.tar.gz"; hash = "sha256-afPTfauIV49IATX0szuOdKLloyqI4XKsyNk8KkasAvg="; }; tlsDepId = "tls-0.1.0-ER2e0jGpBgCkVC-Yp12NgSdHNUtZr52MleJ8roHlUa54"; in stdenv.mkDerivation { pname = "zsmtp"; version = "0.0.0"; src = lib.cleanSource ../.; nativeBuildInputs = [ zig_0_16 ]; # Provide the dependency offline through the project-local package # directory, which the build consults before fetching. postPatch = '' mkdir -p zig-pkg/${tlsDepId} cp -r ${tlsDep}/{build.zig,build.zig.zon,readme.md,src} zig-pkg/${tlsDepId}/ ''; dontConfigure = true; buildPhase = '' runHook preBuild export ZIG_GLOBAL_CACHE_DIR=$TMPDIR/zig-global-cache zig build install -Doptimize=ReleaseSafe --prefix $out runHook postBuild ''; doCheck = true; checkPhase = '' runHook preCheck zig build test runHook postCheck ''; dontInstall = true; meta = { description = "SMTP client and server library for Zig"; license = lib.licenses.mit; mainProgram = "zsmtp"; }; }