# 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 zigDeps = callPackage ./build.zig.zon.nix { }; in stdenv.mkDerivation (finalAttrs: { pname = "zig-paperless"; version = "0.1.0"; # Named rather than filtered, so that editing something outside this list -- # the flake, the README, the virtual machine test that consumes the result # -- does not rebuild the package and, in the test, the whole machine. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./build.zig.zon.nix ./src ./tests/client.zig ./tests/live.zig ./tools ]; }; nativeBuildInputs = [ zig_0_17.hook ]; # A Nix build has no network and the Zig package manager wants one, so the # dependencies are realised by Nix and handed over as a directory. `--system` # forbids fetching outright: a dependency missing from it is a build error # naming the package rather than an attempt to reach the network. 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` and fails in the # sandbox. zigCheckFlags = finalAttrs.zigBuildFlags; # The unit tests are pure and the client tests want only a loopback socket, # which the build sandbox has. The tests against a real server are # compiled here and run by the flake's `checks`. doCheck = true; meta = { description = "A Zig client for the Paperless-ngx REST API"; homepage = "https://git.jcollie.dev/jeff/zig-paperless"; license = lib.licenses.mit; mainProgram = "zig-paperless"; platforms = lib.platforms.unix; }; })