# SPDX-FileCopyrightText: © 2024-2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT { description = "zig-wuffs"; inputs = { nixpkgs = { url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz"; }; 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; in { packages = forAllSystems ( system: let pkgs = makePackages system; in rec { zig-wuffs = pkgs.callPackage ./package.nix { }; default = zig-wuffs; # The dependency set on its own, so that a job wanting to run # `zig build` for something other than the package -- the tests, # say -- can hand the path straight to Zig without building the # package to get at it. zig-deps = pkgs.callPackage ./build.zig.zon.nix { }; } ); devShells = forAllSystems ( system: let pkgs = makePackages system; in { default = pkgs.mkShell { nativeBuildInputs = [ pkgs.git-pages-cli pkgs.pinact pkgs.reuse pkgs.zig_0_17 ] # zon2nix shells out to `zig env` to read the manifest, and # without a Zig on PATH it prints "unable to execute zig" and # exits without writing anything -- which looks exactly like a # regeneration that found no changes. Wrapping it with this # flake's Zig means the one it finds is the one the project # builds with, rather than whatever the caller happens to have. ++ lib.optionals (zon2nix.packages ? ${system}) [ (pkgs.symlinkJoin { name = "zon2nix"; paths = [ zon2nix.packages.${system}.zon2nix ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' wrapProgram $out/bin/zon2nix \ --prefix PATH : ${lib.makeBinPath [ pkgs.zig_0_17 ]} ''; }) ]; }; } ); }; }