zig-zork #
Zork (a.k.a. Dungeon), built with the Zig build system.
This project packages devshane/zork — the
C port of the original 1977–1981 MIT mainframe Zork — using zig build in
place of the original Makefile. The game source is pulled in as a Zig package
dependency; no code is vendored here.
One file of it is replaced. Upstream's dinit.c sets up the game by reading
the database dtextc.dat from a path compiled into the binary;
src/dinit.zig exports the same C symbols but embeds the database with
@embedFile, so the executable is self-contained and runs from anywhere,
with no data file to install.
Source #
The repository lives at https://git.jcollie.dev/jeff/zig-zork:
git clone https://git.jcollie.dev/jeff/zig-zork.git
It is mirrored on Tangled at https://tangled.org/jcollie.dev/zig-zork.
Requirements #
- Zig 0.17
- termcap (headers and library)
- A C compiler is not needed separately — Zig compiles the C sources.
Building #
zig build
The results land in zig-out/:
zig-out/bin/zig-zork— the game, with its data built inzig-out/share/man/man6/dungeon.6— the manpage
To build and play in one step:
zig build run
zig build test plays a few moves and checks that the game answers them.
Build options #
| Option | Default | Description |
|---|---|---|
-Dallow-gdt |
false |
Enable the in-game debugging tool, invoked by typing gdt. Not much use except for debugging. |
-Doptimize=... |
Debug |
Standard Zig optimization mode, e.g. ReleaseSafe or ReleaseFast. |
-Dtarget=... |
native | Standard Zig cross-compilation target. |
Nix #
A flake is included:
# Play the game
nix run .#zig-zork
# Build the package
nix build .#zig-zork
# Development shell with Zig, termcap, and tooling
nix develop
The flake builds with Zig's --system mode using dependencies pre-fetched via
zon2nix; after changing dependencies in
build.zig.zon, regenerate build.zig.zon.nix with:
nix develop -c zon2nix --17 --nix=build.zig.zon.nix build.zig.zon
nixpkgs has no Zig 0.17 yet, so the flake takes the 0.17.0 release from zig-overlay.
Playing #
You are standing in an open field west of a white house, with a boarded front
door. Type commands like open mailbox, go north, or take lamp. See the
dungeon(6) manpage for details, or type help in-game. Save yourself some
grief: don't wake the thief.
References cited #
The entries are kept in the zig-zork collection in Zotero.
- Hashimoto, M. (n.d.). zig-overlay [Nix]. Retrieved October 2, 2026, from https://git.jcollie.dev/jeff/zig-overlay
- Ollie, J. C. (n.d.). zon2nix [Zig]. Retrieved September 22, 2026, from https://github.com/jcollie/zon2nix
- Thomas, S. (n.d.). zork: The DUNGEON (Zork I) source (Version 1.0.3) [C]. Retrieved October 2, 2026, from https://github.com/devshane/zork
- Zig Software Foundation. (2026). Zig 0.17.0: lib/compiler/Maker.zig (Version 0.17.0) [Zig]. https://codeberg.org/ziglang/zig/src/tag/0.17.0/lib/compiler/Maker.zig
- Zig Software Foundation. (2026). Zig 0.17.0: lib/compiler/Maker/Step/Run.zig (Version 0.17.0) [Zig]. https://codeberg.org/ziglang/zig/src/tag/0.17.0/lib/compiler/Maker/Step/Run.zig
- Zig Software Foundation. (2026). Zig 0.17.0: lib/std/Build.zig (Version 0.17.0) [Zig]. https://codeberg.org/ziglang/zig/src/tag/0.17.0/lib/std/Build.zig
- Zig Software Foundation. (2026). Zig 0.17.0: lib/std/Build/Step/Run.zig (Version 0.17.0) [Zig]. https://codeberg.org/ziglang/zig/src/tag/0.17.0/lib/std/Build/Step/Run.zig