build: add initial zig package

This commit is contained in:
CJ van den Berg 2026-02-22 19:44:15 +01:00
parent db5b5217ba
commit a1e5e3e9a5
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
6 changed files with 191 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/.zig-cache/
/zig-out/

122
README.md Normal file
View file

@ -0,0 +1,122 @@
```
_ _ _ _ _ _ _ _ _
| \ | (_) | | | | | \ / | | | | |
| \| |_ __ _| |__ | |_ \ \ _ / /_ _| |_ __| |___
| . ` | |/ _` | '_ \| __| \ ` ' / _` | __|/ _| '_ \
| |\ | | (_| | | | | |_ \ / (_| | |_| (_| | | |
|_| \_|_|\__, |_| |_|\__| \_|_/ \__,_|\__|\__|_| |_|
__/ |
|___/
T H E N I G H T W A T C H
```
![nightwatch](docs/nightwatch.png)
> The city sleeps.
> The files do not.
"FABRICATI DIEM, PVNC"
**The Night Watch** is a file change tracker for directory trees, written
in **Zig**.
It provides:
- A standalone CLI for tracking filesystem changes
- A module for embedding change-tracking into other Zig programs
- Minimal dependencies and consistent, predictable, cross-platform behavior
It does not interfere.
It does not speculate.
It simply keeps watch.
------------------------------------------------------------------------
## Features
- Recursive directory tree tracking
- Deterministic multi-platform support (Linux, FreeBSD, MacOS, Windows)
- Lightweight and fast
- Embeddable Zig module API
- Standalone CLI executable
------------------------------------------------------------------------
# Installation
The Watch is written in **Zig** and built using the Zig build system.
## Requirements
- Zig (currently zig-0.15.2)
## Build CLI
``` bash
zig build
```
The executable will be located in:
`zig-out/bin/nightwatch`
## Install System-Wide
``` bash
zig build install
```
------------------------------------------------------------------------
# Using as a Zig Module
The Night Watch exposes a reusable module that can be imported into
other Zig programs.
In your `build.zig`:
``` zig
const nightwatch = b.dependency("nightwatch", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("nightwatch", nightwatch.module("nightwatch"));
```
In your Zig source:
``` zig
const nightwatch = @import("nightwatch");
```
You now have programmatic access to the tracking engine.
------------------------------------------------------------------------
# CLI Usage
``` bash
nightwatch [{path}..]
```
Run:
``` bash
nightwatch --help
```
for full command documentation.
------------------------------------------------------------------------
# Philosophy
Other tools watch files.
The Night Watch keeps watch over the peace.
It remembers what changed.
It records what vanished.
It notices what arrived at 2:14 AM.
And it writes it down.

46
build.zig Normal file
View file

@ -0,0 +1,46 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("nightwatch", .{
.root_source_file = b.path("src/nightwatch.zig"),
.target = target,
});
const exe = b.addExecutable(.{
.name = "nightwatch",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "nightwatch", .module = mod },
},
}),
});
b.installArtifact(exe);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args|
run_cmd.addArgs(args);
const mod_tests = b.addTest(.{
.root_module = mod,
});
const run_mod_tests = b.addRunArtifact(mod_tests);
const exe_tests = b.addTest(.{
.root_module = exe.root_module,
});
const run_exe_tests = b.addRunArtifact(exe_tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step);
test_step.dependOn(&run_exe_tests.step);
}

13
build.zig.zon Normal file
View file

@ -0,0 +1,13 @@
.{
.name = .nightwatch,
.version = "0.1.0",
.fingerprint = 0xb88932861fde7cb9,
.minimum_zig_version = "0.15.2",
.dependencies = .{},
.paths = .{
"build.zig",
"build.zig.zon",
"src",
"README.md",
},
}

BIN
docs/nightwatch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

8
src/main.zig Normal file
View file

@ -0,0 +1,8 @@
const std = @import("std");
const nightwatch = @import("nightwatch");
pub fn main() !void {
std.debug.print("FABRICATI DIEM, PVNC\n", .{});
}
test "simple test" {}