this post was submitted on 10 Feb 2026
7 points (100.0% liked)

Nix / NixOS

2623 readers
16 users here now

Main links

Videos

founded 2 years ago
MODERATORS
 

RESOLVED: see the edit at the bottom of the post for the solution.

Forgive me if this is not the place to ask this question. If that is the case, I would appreciate some help finding the best place to ask.

I wish to start hacking together a wayland compositor in C and I figured wlroots would be a reasonable place to start. I'm using NixOS with flakes and wish to make a dev shell. Here is the flake.nix that I wrote and figured would work:

# flake.nix
{
  description = "wayland compositor";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs =
    { self, nixpkgs, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
      };
    in {
      devShells."${system}".default =
        (pkgs.mkShell {
          buildInputs = with pkgs; [
            # c tools
            clang-tools
            gcc
            glibc
            gnumake
            gdb
            # wayland tools
            wayland
            wayland-protocols
            wayland-scanner
            wlroots
          ];
        });
    };
}

The problem I am having is that I have to include wlroots headers using:

# some c file
#include <wlroots-0.19/wlr/backend.h>
# note the prefix "wlroots-0.19/"

which differs from how other projects include the shared library on a non-NixOS system. For example, in tinywl, the example compositor in the wlroots repo, wlroots headers are included like this:

# tinywl.c
#include <wlr/backend.h>

Furthermore, even if I do include wlroots headers using the first path, I am unable to build anything since those headers have includes like in tinywl.c.

I might be a little bit out of my depth and that's okay, but I was hoping to have fun hacking together a wayland compositor.

Any help would be greatly appreciated.

EDIT: Per this comment I just needed to add pkg-config to my flake and use pkg-config --cflags wlroots-0.19 to get the right flags for my C compiler. The program still failed to build but only because wlroots depends on the pixman library, so once I included that in the flake as well, compilation succeeded. My flake looks like this now:

{
  description = "wayland compositor";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs =
    { self, nixpkgs, ... }@inputs:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
      };
    in {
      devShells."${system}".default =
        (pkgs.mkShell {
          packages = with pkgs; [
            # for wayland
            pixman
            wlroots
            wayland
            wayland-protocols
            wayland-scanner
            # for c
            pkg-config
            clang-tools
            gcc
            glibc
            gnumake
            gdb
          ];
        });
    };
}
you are viewing a single comment's thread
view the rest of the comments

For now, I'm building using just gcc and make while I learn the intricacies of wayland/wlroots.