Mach v0.3 has been released! For all the details check out the announcement

Standard library

The Mach standard library can be found at: - it is modular by design. Just like the Zig standard library, you can choose which parts to use or not.

Thanks to Zig’s lazy code evaluation and lazy dependency fetching, you really only pay for the parts you use.

Getting started

Add the Mach dependency to your build.zig.zon file:

zig fetch --save$LATEST_COMMIT.tar.gz

Then make it importable by your code in build.zig, e.g.:

pub fn build(b: *std.Build) void {
    // ...

    // Add Mach to our library and executable
    const mach_dep = b.dependency("mach", .{
        .target = target,
        .optimize = optimize,
    lib.root_module.addImport("mach", mach_dep.module("mach"));
    exe.root_module.addImport("mach", mach_dep.module("mach"));

Now in e.g. your src/main.zig you can @import("mach").

(optional) Lazy dependencies

Mach’s stdlib has a handful of external dependencies, downloading them all is usually not a problem. Optionally, if you want to optimize your build and only download what is absolutely neccessary, you can specify which parts of the Mach stdlib you use and have only the dependencies needed for those parts downloaded.

For example, in your build.zig you might specify:

    const mach_dep = b.dependency("mach", .{
        .target = target,
        .optimize = optimize,

        // We only use mach.core and mach.sysaudio, so only fetch the dependencies needed by those.
        .core = true,
        .sysaudio = true,

The options are:

No option specifiedFetch all external dependencies
.core = trueFetch external dependencies needed for @import("mach").core
.sysaudio = trueFetch external dependencies needed for @import("mach").sysaudio
.sysgpu = trueFetch external dependencies needed for @import("mach").sysgpu

An option is only provided if that portion of the stdlib has external dependencies. Remember that Zig’s lazy code evaluation effectively means time is only spent compiling the code you reference.

Ran into trouble?

Feel free to join the Mach Discord community for help.