Home Explore Blog Models CI



nixpkgs

doc/hooks/zig.section.md
7e372d0267dabcdc650ec1a7047ab7391e08f9637e57739b000000030000060d
# zig.hook {#zig-hook}

[Zig](https://ziglang.org/) is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software.

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

## Example code snippet {#zig-hook-example-code-snippet}

```nix
{
  lib,
  stdenv,
  zig,
}:

stdenv.mkDerivation {
  # . . .

  nativeBuildInputs = [ zig.hook ];

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

  dontUseZigCheck = true;

  # . . .
}
```

## Variables controlling zig.hook {#zig-hook-variables-controlling}

### `zig.hook` Exclusive Variables {#zig-hook-exclusive-variables}

The variables below are exclusive to `zig.hook`.

#### `dontUseZigBuild` {#dont-use-zig-build}

Disables using `zigBuildPhase`.

#### `dontUseZigCheck` {#dont-use-zig-check}

Disables using `zigCheckPhase`.

#### `dontUseZigInstall` {#dont-use-zig-install}

Disables using `zigInstallPhase`.

### Similar variables {#zig-hook-similar-variables}

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

| `zig.hook` Variable | `stdenv.mkDerivation` Counterpart |
|---------------------|-----------------------------------|
| `zigBuildFlags`     | `buildFlags`                      |
| `zigCheckFlags`     | `checkFlags`                      |
| `zigInstallFlags`   | `installFlags`                    |

### Variables honored by zig.hook {#zig-hook-variables-honored}

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

- `prefixKey`
- `dontAddPrefix`

Chunks
806eae47 (1st chunk of `doc/hooks/zig.section.md`)
Title: Nixpkgs zig.hook
Summary
This document describes `zig.hook` in Nixpkgs, a component that overrides the default build, check, and install phases for Zig projects. It integrates Zig into the Nixpkgs build system. An example code snippet demonstrates its usage by adding `zig.hook` to `nativeBuildInputs` and setting `zigBuildFlags` or `dontUseZigCheck`. The hook offers exclusive variables like `dontUseZigBuild`, `dontUseZigCheck`, and `dontUseZigInstall` to disable specific phases, as well as `zigBuildFlags`, `zigCheckFlags`, and `zigInstallFlags` which are similar to `stdenv.mkDerivation`'s respective flag variables. It also honors common `stdenv.mkDerivation` variables such as `prefixKey` and `dontAddPrefix`.