base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / am / amdvlk / package.nix
blobf0d60c42a33a4cd3fa7eb98d10c266a66aee56b0
2   stdenv,
3   callPackage,
4   lib,
5   fetchRepoProject,
6   writeScript,
7   cmake,
8   directx-shader-compiler,
9   glslang,
10   ninja,
11   patchelf,
12   perl,
13   pkg-config,
14   python3,
15   expat,
16   libdrm,
17   ncurses,
18   openssl,
19   wayland,
20   xorg,
21   zlib,
23 let
25   suffix = if stdenv.system == "x86_64-linux" then "64" else "32";
26   # Fix https://github.com/NixOS/nixpkgs/issues/348903 until the glslang update to 15.0.0 is merged into master
27   glslang_fixed = glslang.overrideAttrs (finalAttrs: oldAttrs: { cmakeFlags = [ ]; });
30 stdenv.mkDerivation (finalAttrs: {
31   pname = "amdvlk";
32   version = "2024.Q3.3";
34   src = fetchRepoProject {
35     name = "amdvlk-src";
36     manifest = "https://github.com/GPUOpen-Drivers/AMDVLK.git";
37     rev = "refs/tags/v-${finalAttrs.version}";
38     hash = "sha256-wIPubMsSaNGTykD/K0gxdba128TqW5nu4CjXoLkprc0=";
39   };
41   buildInputs =
42     [
43       expat
44       libdrm
45       ncurses
46       openssl
47       wayland
48       zlib
49     ]
50     ++ (with xorg; [
51       libX11
52       libxcb
53       xcbproto
54       libXext
55       libXrandr
56       libXft
57       libxshmfence
58     ]);
60   nativeBuildInputs =
61     [
62       cmake
63       directx-shader-compiler
64       glslang_fixed
65       ninja
66       patchelf
67       perl
68       pkg-config
69       python3
70     ]
71     ++ (with python3.pkgs; [
72       jinja2
73       ruamel-yaml
74     ]);
76   rpath = lib.makeLibraryPath (
77     [
78       libdrm
79       openssl
80       stdenv.cc.cc
81       zlib
82     ]
83     ++ (with xorg; [
84       libX11
85       libxcb
86       libxshmfence
87     ])
88   );
90   cmakeDir = "../drivers/xgl";
92   installPhase = ''
93     runHook preInstall
95     install -Dm755 -t $out/lib icd/amdvlk${suffix}.so
96     install -Dm644 -t $out/share/vulkan/icd.d icd/amd_icd${suffix}.json
97     install -Dm644 -t $out/share/vulkan/implicit_layer.d icd/amd_icd${suffix}.json
99     patchelf --set-rpath "$rpath" $out/lib/amdvlk${suffix}.so
101     runHook postInstall
102   '';
104   # Keep the rpath, otherwise vulkaninfo and vkcube segfault
105   dontPatchELF = true;
107   passthru.updateScript = writeScript "update.sh" ''
108     #!/usr/bin/env nix-shell
109     #!nix-shell -i bash -p coreutils curl gnused jq common-updater-scripts
111     packagePath="pkgs/by-name/am/amdvlk/package.nix"
113     function setHash() {
114       sed -i $packagePath -e 's,sha256 = "[^'"'"'"]*",sha256 = "'"$1"'",'
115     }
117     version="$(curl -sL "https://api.github.com/repos/GPUOpen-Drivers/AMDVLK/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
118     sed -i $packagePath -e 's/version = "[^'"'"'"]*"/version = "'"$version"'"/'
120     setHash "$(nix-instantiate --eval -A lib.fakeSha256 | xargs echo)"
121     hash="$(nix to-base64 $(nix-build -A amdvlk 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true))"
122     setHash "$hash"
123   '';
125   passthru.impureTests = {
126     amdvlk = callPackage ./test.nix { };
127   };
129   meta = {
130     description = "AMD Open Source Driver For Vulkan";
131     homepage = "https://github.com/GPUOpen-Drivers/AMDVLK";
132     changelog = "https://github.com/GPUOpen-Drivers/AMDVLK/releases/tag/v-${finalAttrs.version}";
133     license = lib.licenses.mit;
134     platforms = [
135       "x86_64-linux"
136       "i686-linux"
137     ];
138     maintainers = with lib.maintainers; [ Flakebi ];
139   };