Something went wrong. Try again.
A Zig client for the Paperless-ngx REST API, with streaming uploads, task waiting and a command-line tool.
Something went wrong. Try again.
zig-paperless flake.nix
3.5 kB · 108 lines
Nix
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
{ description = "A Zig client for the Paperless-ngx REST API";
inputs = { nixpkgs = { url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; }; # Mine, not the one in nixpkgs, which is Jari Vetoniemi's original and # takes different options. zon2nix = { url = "github:jcollie/zon2nix"; inputs.nixpkgs.follows = "nixpkgs"; }; };
outputs = { nixpkgs, zon2nix, ... }: let inherit (nixpkgs) lib; makePackages = system: import nixpkgs { inherit system; }; forAllSystems = lib.genAttrs lib.systems.flakeExposed; # The virtual machine test is a NixOS one, so it exists only where NixOS # does. Without this `nix flake check` tries to evaluate it for Darwin # and fails before it has run anything. forLinuxSystems = lib.genAttrs ( lib.filter (system: lib.hasSuffix "-linux" system) lib.systems.flakeExposed ); in { packages = forAllSystems ( system: let pkgs = makePackages system; in rec { zig-paperless = pkgs.callPackage ./package.nix { }; default = zig-paperless; # The dependency farm on its own, for a job that runs `zig build` # for something other than the package -- the documentation -- and # needs the same dependencies without building the package. zig-deps = pkgs.callPackage ./build.zig.zon.nix { }; } );
# The client against a real Paperless-ngx, on a machine of its own: the # models are only as right as the JSON a real server sends, and the # schema the server publishes is not always the JSON it sends. checks = forLinuxSystems ( system: let pkgs = makePackages system; zig-paperless = pkgs.callPackage ./package.nix { }; in { inherit zig-paperless; paperless = pkgs.testers.runNixOSTest ( import ./tests/nixos/paperless.nix { inherit zig-paperless; } ); } );
devShells = forAllSystems ( system: let pkgs = makePackages system; in { default = pkgs.mkShell { name = "zig-paperless"; nativeBuildInputs = [ pkgs.zig_0_17 pkgs.git-pages-cli pkgs.reuse
# Wrapped so that the Zig it shells out to for `zig env` is this # project's rather than whatever happens to be on the caller's # PATH -- without one it prints "unable to execute zig" and # stops, having written nothing, which leaves the previous # generated file in place looking untouched. (pkgs.symlinkJoin { name = "zon2nix"; paths = [ zon2nix.packages.${pkgs.stdenv.hostPlatform.system}.zon2nix ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' wrapProgram $out/bin/zon2nix \ --prefix PATH : ${lib.makeBinPath [ pkgs.zig_0_17 ]} ''; }) ] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.kcov ]; }; } ); };}