nixpkgs/doc/hooks/zig.section.md
Jared Baur e20232eab6
zig: move ZIG_GLOBAL_CACHE_DIR setup to configurePhase
This allows users to put zig in their `mkShell` without ending up with a
ZIG_GLOBAL_CACHE_DIR value set that points back to a location that only
would exist in the sandbox.
2026-02-07 17:32:18 -08:00

1.7 KiB

Zig

Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software.

In Nixpkgs, zig overrides the default build, check and install phases.

Example code snippet

{
  lib,
  stdenv,
  zig,
}:

stdenv.mkDerivation {
  # . . .

  nativeBuildInputs = [ zig ];

  zigBuildFlags = [ "-Dman-pages=true" ];

  dontUseZigCheck = true;

  # . . .
}

Variables controlling zig

zig Exclusive Variables

The variables below are exclusive to zig.

dontUseZigConfigure

Disables using zigConfigurePhase.

dontUseZigBuild

Disables using zigBuildPhase.

dontUseZigCheck

Disables using zigCheckPhase.

dontUseZigInstall

Disables using zigInstallPhase.

dontSetZigDefaultFlags

Disables using a set of default flags when performing zig builds.

Similar variables

The following variables are similar to their stdenv.mkDerivation counterparts.

zig Variable stdenv.mkDerivation Counterpart
zigBuildFlags buildFlags
zigCheckFlags checkFlags
zigInstallFlags installFlags

Variables honored by zig

The following variables commonly used by stdenv.mkDerivation are honored by zig.

  • prefixKey
  • dontAddPrefix