Yoe mgr (an exercise in Zig)

Recently, I have been interested in using Zig as a C build/test tool. With that in mind, I started a research project:

This might eventually evolve into a system management program and perhaps replace the Yoe Updater, which is written in shell.

The first step was to get it to build and link against a C library. We may or may not use D-Bus long-term, but this was a useful first step. Zig is still moving fast, so it took some work to create the build file. The last step (linking in libsystemd) stumped me for a while, but the solution was simple once someone told me:

The resulting build file is:

const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const exe = b.addExecutable(.{
        .name = "mgr",
        .target = target,

        .file = b.path("main.c"),
        .flags = &[_][]const u8{},


Not bad ā€¦

Thinking about the design of mgr, some thoughts come to mind:

  • use systemd as much as possible
  • manage both factory init and updates
  • integrate well with Simple IoT ā€“ perhaps over D-Bus
  • run as a daemon in a running system as well as PID0 in an initramfs.

Some learning resources for zig

Cool articles in blog form

Videos on YT

and of course the Zig Guide

Thanks @khem for the great resources. I also started through Ziglings ā€“ seems to be a good resource if you like to learn by doing.