diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/amdvlk')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/amdvlk/default.nix | 117 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/libraries/amdvlk/test.nix | 49 |
2 files changed, 166 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/amdvlk/default.nix b/nixpkgs/pkgs/development/libraries/amdvlk/default.nix new file mode 100644 index 000000000000..4dec50bcc776 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/amdvlk/default.nix @@ -0,0 +1,117 @@ +{ stdenv +, callPackage +, lib +, fetchRepoProject +, writeScript +, cmake +, directx-shader-compiler +, glslang +, ninja +, patchelf +, perl +, pkg-config +, python3 +, expat +, libdrm +, ncurses +, openssl +, wayland +, xorg +, zlib +}: +let + + suffix = if stdenv.system == "x86_64-linux" then "64" else "32"; + +in stdenv.mkDerivation rec { + pname = "amdvlk"; + version = "2023.Q2.3"; + + src = fetchRepoProject { + name = "${pname}-src"; + manifest = "https://github.com/GPUOpen-Drivers/AMDVLK.git"; + rev = "refs/tags/v-${version}"; + sha256 = "FoDXg0ocKBtwY22UJJCnyLn99CpmDE9HOMw7iiZkf6k="; + }; + + buildInputs = [ + expat + libdrm + ncurses + openssl + wayland + xorg.libX11 + xorg.libxcb + xorg.xcbproto + xorg.libXext + xorg.libXrandr + xorg.libXft + xorg.libxshmfence + zlib + ]; + + nativeBuildInputs = [ + cmake + directx-shader-compiler + glslang + ninja + patchelf + perl + pkg-config + python3 + ]; + + rpath = lib.makeLibraryPath [ + libdrm + openssl + stdenv.cc.cc.lib + xorg.libX11 + xorg.libxcb + xorg.libxshmfence + zlib + ]; + + cmakeDir = "../drivers/xgl"; + + installPhase = '' + runHook preInstall + + install -Dm755 -t $out/lib icd/amdvlk${suffix}.so + install -Dm644 -t $out/share/vulkan/icd.d icd/amd_icd${suffix}.json + install -Dm644 -t $out/share/vulkan/implicit_layer.d icd/amd_icd${suffix}.json + + patchelf --set-rpath "$rpath" $out/lib/amdvlk${suffix}.so + + runHook postInstall + ''; + + # Keep the rpath, otherwise vulkaninfo and vkcube segfault + dontPatchELF = true; + + passthru.updateScript = writeScript "update.sh" '' + #!/usr/bin/env nix-shell + #!nix-shell -i bash -p coreutils curl gnused jq common-updater-scripts + + function setHash() { + sed -i "pkgs/development/libraries/amdvlk/default.nix" -e 's,sha256 = "[^'"'"'"]*",sha256 = "'"$1"'",' + } + + version="$(curl -sL "https://api.github.com/repos/GPUOpen-Drivers/AMDVLK/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)" + sed -i "pkgs/development/libraries/amdvlk/default.nix" -e 's/version = "[^'"'"'"]*"/version = "'"$version"'"/' + + setHash "$(nix-instantiate --eval -A lib.fakeSha256 | xargs echo)" + hash="$(nix to-base64 $(nix-build -A amdvlk 2>&1 | tail -n3 | grep 'got:' | cut -d: -f2- | xargs echo || true))" + setHash "$hash" + ''; + + passthru.impureTests = { amdvlk = callPackage ./test.nix {}; }; + + meta = with lib; { + description = "AMD Open Source Driver For Vulkan"; + homepage = "https://github.com/GPUOpen-Drivers/AMDVLK"; + changelog = "https://github.com/GPUOpen-Drivers/AMDVLK/releases/tag/v-${version}"; + license = licenses.mit; + platforms = [ "x86_64-linux" "i686-linux" ]; + maintainers = with maintainers; [ Flakebi ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/amdvlk/test.nix b/nixpkgs/pkgs/development/libraries/amdvlk/test.nix new file mode 100644 index 000000000000..e76e6dce9eaf --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/amdvlk/test.nix @@ -0,0 +1,49 @@ +{ lib, makeImpureTest, coreutils, amdvlk, vulkan-tools }: +makeImpureTest { + name = "amdvlk"; + testedPackage = "amdvlk"; + + sandboxPaths = [ "/sys" "/dev/dri" ]; + + nativeBuildInputs = [ vulkan-tools ]; + + VK_ICD_FILENAMES = "${amdvlk}/share/vulkan/icd.d/amd_icd64.json"; + XDG_RUNTIME_DIR = "/tmp"; + + # AMDVLK needs access to /dev/dri/card0 (or another card), but normally it is rw-rw---- + # Change the permissions to be rw for everyone + prepareRunCommands = '' + function reset_perms() + { + # Reset permissions to previous state + for card in /dev/dri/card*; do + sudo ${coreutils}/bin/chmod "0''${cardPerms[$card]}" $card + done + } + + # Save permissions on /dev/dri/card* + declare -A cardPerms + for card in /dev/dri/card*; do + cardPerms[$card]=$(stat -c "%a" $card) + done + + sudo ${coreutils}/bin/chmod o+rw /dev/dri/card* + trap reset_perms EXIT + ''; + + testScript = '' + # Check that there is at least one card with write-access + if ! ls -l /dev/dri/card* | cut -b8-9 | grep -q rw; then + echo 'AMDVLK needs rw access to /dev/dri/card0 or a fitting card, please run `sudo chmod o+rw /dev/dri/card*`' + exit 1 + fi + + vulkaninfo --summary + echo "Checking version" + vulkaninfo --summary | grep '= ${amdvlk.version}' + ''; + + meta = with lib.maintainers; { + maintainers = [ Flakebi ]; + }; +} |