# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT { lib, stdenv, callPackage, zig_0_17, }: let # Generated from build.zig.zon by zon2nix; regenerate with # nix develop -c zon2nix --17 --nix=build.zig.zon.nix build.zig.zon # # A Nix build has no network and the Zig package manager wants one, so the # dependencies are fetched by Nix and handed to Zig as an already-populated # package directory. zigDeps = callPackage ./build.zig.zon.nix { }; in stdenv.mkDerivation (finalAttrs: { pname = "zig-snmp"; version = "0.2.0"; # Named rather than filtered, so that editing something outside this list -- # the flake, a scratch file, the NixOS test that consumes the result -- does # not rebuild the package and, in the test, the whole virtual machine. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./build.zig.zon.nix ./src ./tests ./tools ./LICENSES ./README.md ./REUSE.toml ]; }; nativeBuildInputs = [ zig_0_17 ]; # `--system` does not merely offer the directory, it forbids fetching # outright: a dependency missing from it is a build error naming the # package, rather than a silent attempt to reach the network that fails # somewhere less legible. zigBuildFlags = [ "--system" "${zigDeps}" ]; # 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 unit tests are pure and the end-to-end ones only need a loopback # socket, which the build sandbox has. The oracle tests want net-snmp's # snmpd, which is deliberately *not* a check input: they skip when it is # absent, so the package builds without pulling it in. doCheck = true; meta = { description = "An SNMP manager library and command line tools for Zig"; homepage = "https://git.jcollie.dev/jeff/zig-snmp"; license = lib.licenses.mit; mainProgram = "zig-snmp"; platforms = lib.platforms.unix; }; })