USING RAYLIB WITH ZIG ON NIXOS
KunkkaFollow
Last update: 2025-08-28,
8 mins to read
↳
Premises
- Know about the nix package manager.
- Know about the nixos operating system.
- Know about the feature. ref
- Know your Zig version
Steps
1. Init project
2. Prepare a file
Remember to place it in the root directory of the project
4. Two ways to use raylib with zig
1. With raylib bindings for zig
- Run this in your_prj_dir command to fetch raylib-zig dependency
for zig version 0.15.1
for zig version 0.14.x
If you don’t see the following result, please check your Zig version.
- Next, check your build.zig.zon file to ensure that the dependency is added
- Add this to the file after exe_mod creating
- Add this after defining exe module
- Done, now I believe that you can use raylib-zig dependency with zig types system.
- A simple file to test
- Build and run
- build nix dev environment
- then build the zig project
2. Without bindings (use cImport direct) and zig 0.15
Use this approach if you are concerned about the maintenance status of the raylib-zig package and the raylib version. Since the latest raylib requires min_ver = "0.15.1" (as of 2025-08-28), this is a good chance to use Zig 0.15.1 in our Nix dev environment.
- We changed the file a bit to install Zig 0.15.1 in our Nix dev environment.
- Fetch raylib resource
- Modify to use raylib
Add this after exe definition
- Test with a simple file
We use cImport, so the syntax will be slightly different.
- Build and run
- build nix dev environment
- then build the zig project
Result
