Setting up vulkan for development

Hi, I’m trying to build a C++ project that uses Cmake and Vulkan.
The standard way to find vulkan across platform in Cmake is to include the find_vulkan.cmake module. Code for the module here.
From the source code, it works by checking the “VULKAN_SDK” environment variable and expects the lib/bin/include folders to be there.

I know I can use environment.variables.VULKAN_SDK = "directoryhere"; to set the environment variable, but the vulkan sdk is split over many packages. (vulkan-headers, vulkan-tools, vulkan-tools-lunarg, vulkan-loader, vulkan-validation-layers, vulkan-extension-layer, glslang)

For example, I want both vulkan-tools and vulkan-tools-lunarg (both have their own bin directory, so sadly a simple symlink wont work) to be in the one VULKAN_SDK directory.

I’m guessing the best thing to do would be to somehow copy all the packages into one directory, then set an environment variable there? This is just my second day using NixOS, I don’t know the best way to go about this.

Hi!
I’m not developing Vulkan applications, but I compile some from time to time.
Usually, I create a shell.nix for use with direnv and the great nix-direnv. The shell.nix lists the various needed packages in buildInputs and I add more of the Vulkan packages until it compiles. :wink:

I never needed to set VULKAN_SDK for anything. Take that with a grain of salt though, I also never tried to use the validation layers. If it doesn’t work out of the box, I could imagine to make it work with VK_LAYER_PATH somehow, that way it can be different folders.

Usually, my shell.nix looks somehow like this:

{ pkgs ? (import <nixpkgs> {}) }:
with pkgs;
mkShell {
  buildInputs = [
    # put packages here.
    glslang # or shaderc
    vulkan-headers
    vulkan-loader
    vulkan-validation-layers # maybe?
    # glm and whatnot …
  ];

  # If it doesn’t get picked up through nix magic
  VULKAN_SDK = "${vulkan-validation-layers}/share/vulkan/explicit_layer.d"
}