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

ref

  1. 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.

  1. Next, check your build.zig.zon file to ensure that the dependency is added
  1. Add this to the file after exe_mod creating
  1. Add this after defining exe module
  1. Done, now I believe that you can use raylib-zig dependency with zig types system.
  • A simple file to test
  1. 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.

  1. We changed the file a bit to install Zig 0.15.1 in our Nix dev environment.
  1. Fetch raylib resource
  1. Modify to use raylib

Add this after exe definition

  1. Test with a simple file

We use cImport, so the syntax will be slightly different.

  1. Build and run
  • build nix dev environment
  • then build the zig project

Result

image


▶  Find out more: