Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv
2, callPackage
3, lib
4, fetchRepoProject
5, writeScript
6, cmake
7, directx-shader-compiler
8, glslang
9, ninja
10, patchelf
11, perl
12, pkg-config
13, python3
14, expat
15, libdrm
16, ncurses
17, openssl
18, wayland
19, xorg
20, zlib
21}:
22let
23
24 suffix = if stdenv.system == "x86_64-linux" then "64" else "32";
25
26in stdenv.mkDerivation rec {
27 pname = "amdvlk";
28 version = "2023.Q2.1";
29
30 src = fetchRepoProject {
31 name = "${pname}-src";
32 manifest = "https://github.com/GPUOpen-Drivers/AMDVLK.git";
33 rev = "refs/tags/v-${version}";
34 sha256 = "znjv50seqN2Rdzwnu/5ks6q1uiUacM/Z5fzMyCgv0b8=";
35 };
36
37 buildInputs = [
38 expat
39 libdrm
40 ncurses
41 openssl
42 wayland
43 xorg.libX11
44 xorg.libxcb
45 xorg.xcbproto
46 xorg.libXext
47 xorg.libXrandr
48 xorg.libXft
49 xorg.libxshmfence
50 zlib
51 ];
52
53 nativeBuildInputs = [
54 cmake
55 directx-shader-compiler
56 glslang
57 ninja
58 patchelf
59 perl
60 pkg-config
61 python3
62 ];
63
64 rpath = lib.makeLibraryPath [
65 libdrm
66 openssl
67 stdenv.cc.cc.lib
68 xorg.libX11
69 xorg.libxcb
70 xorg.libxshmfence
71 zlib
72 ];
73
74 cmakeDir = "../drivers/xgl";
75
76 installPhase = ''
77 runHook preInstall
78
79 install -Dm755 -t $out/lib icd/amdvlk${suffix}.so
80 install -Dm644 -t $out/share/vulkan/icd.d icd/amd_icd${suffix}.json
81 install -Dm644 -t $out/share/vulkan/implicit_layer.d icd/amd_icd${suffix}.json
82
83 patchelf --set-rpath "$rpath" $out/lib/amdvlk${suffix}.so
84
85 runHook postInstall
86 '';
87
88 # Keep the rpath, otherwise vulkaninfo and vkcube segfault
89 dontPatchELF = true;
90
91 passthru.updateScript = writeScript "update.sh" ''
92 #!/usr/bin/env nix-shell
93 #!nix-shell -i bash -p coreutils curl gnused jq common-updater-scripts
94
95 function setHash() {
96 sed -i "pkgs/development/libraries/amdvlk/default.nix" -e 's,sha256 = "[^'"'"'"]*",sha256 = "'"$1"'",'
97 }
98
99 version="$(curl -sL "https://api.github.com/repos/GPUOpen-Drivers/AMDVLK/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
100 sed -i "pkgs/development/libraries/amdvlk/default.nix" -e 's/version = "[^'"'"'"]*"/version = "'"$version"'"/'
101
102 setHash "$(nix-instantiate --eval -A lib.fakeSha256 | xargs echo)"
103 hash="$(nix to-base64 $(nix-build -A amdvlk 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true))"
104 setHash "$hash"
105 '';
106
107 passthru.impureTests = { amdvlk = callPackage ./test.nix {}; };
108
109 meta = with lib; {
110 description = "AMD Open Source Driver For Vulkan";
111 homepage = "https://github.com/GPUOpen-Drivers/AMDVLK";
112 changelog = "https://github.com/GPUOpen-Drivers/AMDVLK/releases/tag/v-${version}";
113 license = licenses.mit;
114 platforms = [ "x86_64-linux" "i686-linux" ];
115 maintainers = with maintainers; [ Flakebi ];
116 };
117}