{
  lib,
  stdenv,
  wayland,
  wayland-protocols,
  wayland-scanner,
  libxkbcommon,
  libGL,
  mesa,
  glibc,
  pkg-config,
}: let
  fs = lib.fileset;
  s = ../.;
in
  stdenv.mkDerivation {
    pname = "chroma";
    version = "1.0.0";

    src = fs.toSource {
      root = s;
      fileset = fs.unions [
        (s + /include)
        (s + /protocols)
        (s + /src)

        (s + /Makefile)
      ];
    };

    buildInputs = [
      # Wayland libraries
      wayland.dev
      wayland-protocols
      wayland-scanner
      libxkbcommon

      # EGL/OpenGL libraries
      libGL
      mesa

      # System libraries
      glibc.dev
    ];

    nativeBuildInputs = [
      pkg-config
    ];

    makeFlags = [
      "PREFIX=$(out)"
      "SYSTEMD_DIR=$(out)/lib/systemd/system"
    ];

    postInstall = ''
      install -Dm755 ${../chroma.conf.sample} $out/share/chroma.conf.sample
    '';

    meta = {
      description = "Super-fast, lightweight and efficient wallpaper daemon for Wayland compositors";
      license = lib.licenses.mpl20;
      mainProgram = "chroma";
      maintainers = with lib.maitainers; [NotAShelf];
    };
  }
