2021-08-05 21:33:18 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-10-16 20:44:37 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, glslang
|
2021-08-05 21:33:18 +00:00
|
|
|
, libX11
|
2020-10-16 20:44:37 +00:00
|
|
|
, libxcb
|
|
|
|
, libXrandr
|
2021-08-05 21:33:18 +00:00
|
|
|
, spirv-headers
|
|
|
|
, spirv-tools
|
|
|
|
, vulkan-headers
|
2020-10-16 20:44:37 +00:00
|
|
|
, wayland
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-08-05 21:33:18 +00:00
|
|
|
# vulkan-validation-layers requires a custom glslang & robin-hood-hashing
|
|
|
|
# version, while glslang requires custom versions for spirv-tools and spirv-headers.
|
|
|
|
#
|
|
|
|
# The git hashes required for all of these deps is documented upstream here:
|
|
|
|
# https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/scripts/known_good.json
|
|
|
|
# and https://github.com/KhronosGroup/glslang/blob/master/known_good.json
|
2021-01-05 17:05:55 +00:00
|
|
|
localSpirvHeaders = spirv-headers.overrideAttrs (_: {
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "SPIRV-Headers";
|
2021-08-05 21:33:18 +00:00
|
|
|
rev = "dafead1765f6c1a5f9f8a76387dcb2abe4e54acd"; # pin
|
|
|
|
sha256 = "1kj6wcx9y7r1xyg8n7ai2pzrg9ira7hbakr45wh5p4zyxh0m45n8";
|
2021-01-05 17:05:55 +00:00
|
|
|
};
|
|
|
|
});
|
2020-10-16 20:44:37 +00:00
|
|
|
localGlslang = (glslang.override {
|
|
|
|
argSpirv-tools = spirv-tools.overrideAttrs (_: {
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "SPIRV-Tools";
|
2021-08-05 21:33:18 +00:00
|
|
|
rev = "dc72924cb31cd9f3dbc3eb47e9d926cf641e3a07"; # pin
|
|
|
|
sha256 = "0pxgbq6xapw9hgrzb3rk5cylzgg1y1bkqz5wxzwqls63pwga5912";
|
2020-10-16 20:44:37 +00:00
|
|
|
};
|
|
|
|
});
|
2021-01-05 17:05:55 +00:00
|
|
|
argSpirv-headers = localSpirvHeaders;
|
2020-10-16 20:44:37 +00:00
|
|
|
}).overrideAttrs (_: {
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "glslang";
|
2021-08-05 21:33:18 +00:00
|
|
|
rev = "18eef33bd7a4bf5ad8c69f99cb72022608cf6e73"; # pin
|
|
|
|
sha256 = "0wwj7q509pkp8wj7120g1n2ddl4x2r03ljf5czd9794ji6yraidn";
|
2020-10-16 20:44:37 +00:00
|
|
|
};
|
|
|
|
});
|
2021-08-05 21:33:18 +00:00
|
|
|
robin-hood-hashing = fetchFromGitHub {
|
|
|
|
owner = "martinus";
|
|
|
|
repo = "robin-hood-hashing";
|
|
|
|
rev = "3.11.2"; # pin
|
|
|
|
sha256 = "0103mnqpmka1smy0arnrbihlvi7i8xr5im0px8wn4faw4flikkcm";
|
|
|
|
};
|
2020-10-16 20:44:37 +00:00
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "vulkan-validation-layers";
|
2021-08-05 21:33:18 +00:00
|
|
|
version = "1.2.182.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
# If we were to use "dev" here instead of headers, the setupHook would be
|
|
|
|
# placed in that output instead of "out".
|
|
|
|
outputs = ["out" "headers"];
|
|
|
|
outputInclude = "headers";
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
src = (assert version == vulkan-headers.version;
|
|
|
|
fetchFromGitHub {
|
|
|
|
owner = "KhronosGroup";
|
|
|
|
repo = "Vulkan-ValidationLayers";
|
|
|
|
rev = "sdk-${version}";
|
|
|
|
sha256 = "1fnmb7vbm7y1x67bf1xiwdrpj9j4lkvhk9xhb6hp6x2aryvcyrnc";
|
|
|
|
});
|
|
|
|
|
|
|
|
# Include absolute paths to layer libraries in their associated
|
|
|
|
# layer definition json files.
|
|
|
|
postPatch = ''
|
|
|
|
sed "s|\([[:space:]]*set(INSTALL_DEFINES \''${INSTALL_DEFINES} -DRELATIVE_LAYER_BINARY=\"\)\(\$<TARGET_FILE_NAME:\''${TARGET_NAME}>\")\)|\1$out/lib/\2|" -i layers/CMakeLists.txt
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2021-08-05 21:33:18 +00:00
|
|
|
libX11
|
2020-10-16 20:44:37 +00:00
|
|
|
libxcb
|
|
|
|
libXrandr
|
2021-08-05 21:33:18 +00:00
|
|
|
vulkan-headers
|
2020-10-16 20:44:37 +00:00
|
|
|
wayland
|
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DGLSLANG_INSTALL_DIR=${localGlslang}"
|
2021-01-05 17:05:55 +00:00
|
|
|
"-DSPIRV_HEADERS_INSTALL_DIR=${localSpirvHeaders}"
|
2021-08-05 21:33:18 +00:00
|
|
|
"-DROBIN_HOOD_HASHING_INSTALL_DIR=${robin-hood-hashing}"
|
2020-11-19 00:13:47 +00:00
|
|
|
"-DBUILD_LAYER_SUPPORT_FILES=ON"
|
2021-08-05 21:33:18 +00:00
|
|
|
# Hide dev warnings that are useless for packaging
|
|
|
|
"-Wno-dev"
|
2020-10-16 20:44:37 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
# Tests require access to vulkan-compatible GPU, which isn't
|
|
|
|
# available in Nix sandbox. Fails with VK_ERROR_INCOMPATIBLE_DRIVER.
|
|
|
|
doCheck = false;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2021-01-05 17:05:55 +00:00
|
|
|
description = "The official Khronos Vulkan validation layers";
|
|
|
|
homepage = "https://github.com/KhronosGroup/Vulkan-ValidationLayers";
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
license = licenses.asl20;
|
|
|
|
maintainers = [ maintainers.ralith ];
|
|
|
|
};
|
|
|
|
}
|