nixpkgs/pkgs/development/libraries/amdvlk/default.nix

110 lines
2.5 KiB
Nix
Raw Normal View History

2020-03-11 06:57:33 +00:00
{ stdenv
, lib
, fetchRepoProject
2021-12-14 11:32:55 +00:00
, writeScript
2020-03-11 06:57:33 +00:00
, cmake
, ninja
, patchelf
, perl
, pkg-config
2020-03-11 06:57:33 +00:00
, python3
, expat
, libdrm
, ncurses
, openssl
, wayland
, xorg
, zlib
}:
2020-07-21 14:58:30 +00:00
let
2020-03-11 06:57:33 +00:00
2020-07-21 14:58:30 +00:00
suffix = if stdenv.system == "x86_64-linux" then "64" else "32";
in stdenv.mkDerivation rec {
2020-03-11 06:57:33 +00:00
pname = "amdvlk";
2022-01-19 10:35:10 +00:00
version = "2022.Q1.1";
2020-03-11 06:57:33 +00:00
src = fetchRepoProject {
name = "${pname}-src";
manifest = "https://github.com/GPUOpen-Drivers/AMDVLK.git";
rev = "refs/tags/v-${version}";
2022-01-19 10:35:10 +00:00
sha256 = "jdAFIC2JYPqCADx/73KM6E3rLFWF4SlEdY9lCK1NOhU=";
2020-03-11 06:57:33 +00:00
};
buildInputs = [
expat
2021-12-14 11:32:55 +00:00
libdrm
2020-03-11 06:57:33 +00:00
ncurses
openssl
wayland
xorg.libX11
xorg.libxcb
xorg.xcbproto
xorg.libXext
xorg.libXrandr
xorg.libXft
xorg.libxshmfence
zlib
];
nativeBuildInputs = [
cmake
ninja
patchelf
perl
pkg-config
2020-03-11 06:57:33 +00:00
python3
];
rpath = lib.makeLibraryPath [
libdrm
openssl
2020-03-11 06:57:33 +00:00
stdenv.cc.cc.lib
xorg.libX11
xorg.libxcb
xorg.libxshmfence
];
cmakeDir = "../drivers/xgl";
installPhase = ''
2021-12-14 11:32:55 +00:00
runHook preInstall
2020-07-21 14:58:30 +00:00
install -Dm755 -t $out/lib icd/amdvlk${suffix}.so
2021-04-22 09:54:59 +00:00
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
2020-03-11 06:57:33 +00:00
2020-07-21 14:58:30 +00:00
patchelf --set-rpath "$rpath" $out/lib/amdvlk${suffix}.so
2021-12-14 11:32:55 +00:00
runHook postInstall
2020-03-11 06:57:33 +00:00
'';
# Keep the rpath, otherwise vulkaninfo and vkcube segfault
dontPatchELF = true;
2021-12-14 11:32:55 +00:00
passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl gnused jq common-updater-scripts
function setHash() {
2022-01-19 10:35:10 +00:00
sed -i "pkgs/development/libraries/amdvlk/default.nix" -e 's,sha256 = "[^'"'"'"]*",sha256 = "'"$1"'",'
2021-12-14 11:32:55 +00:00
}
version="$(curl -sL "https://api.github.com/repos/GPUOpen-Drivers/AMDVLK/releases?per_page=1" | jq '.[0].tag_name | split("-") | .[1]' --raw-output)"
2022-01-19 10:35:10 +00:00
sed -i "pkgs/development/libraries/amdvlk/default.nix" -e 's/version = "[^'"'"'"]*"/version = "'"$version"'"/'
2021-12-14 11:32:55 +00:00
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"
'';
meta = with lib; {
2020-03-11 06:57:33 +00:00
description = "AMD Open Source Driver For Vulkan";
homepage = "https://github.com/GPUOpen-Drivers/AMDVLK";
2020-08-08 10:18:21 +00:00
changelog = "https://github.com/GPUOpen-Drivers/AMDVLK/releases/tag/v-${version}";
2020-03-11 06:57:33 +00:00
license = licenses.mit;
2020-07-21 14:58:30 +00:00
platforms = [ "x86_64-linux" "i686-linux" ];
maintainers = with maintainers; [ Flakebi ];
2020-03-11 06:57:33 +00:00
};
}