115 lines
3.2 KiB
Nix
115 lines
3.2 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
fetchFromGitHub,
|
|
cmake,
|
|
ninja,
|
|
pkg-config,
|
|
python3,
|
|
boost,
|
|
curl,
|
|
openssl,
|
|
systemd,
|
|
libdrm,
|
|
ncurses,
|
|
protobuf,
|
|
elfutils,
|
|
zlib,
|
|
rapidjson,
|
|
util-linux, # provides libuuid
|
|
xz, # provides liblzma
|
|
}:
|
|
|
|
# AMD XRT (Xilinx Runtime) userspace library for NPU (XDNA 2) devices.
|
|
#
|
|
# This package builds the XRT base library from the commit pinned as a
|
|
# submodule in amd/xdna-driver. It provides:
|
|
# $out/lib/libxrt_coreutil.so — core utility library (linked by flm)
|
|
# $out/lib/libxrt_core.so — platform-independent core
|
|
# $out/include/xrt/ — public C++ headers
|
|
# $out/include/experimental/
|
|
#
|
|
# The xrt source tree lives under the src/ subdirectory of the Xilinx/XRT
|
|
# repository (see src/CMakeLists.txt which includes CMake/nativeLnx.cmake).
|
|
#
|
|
# XRT version 2.19.0 — pinned to the commit used by amd/xdna-driver main
|
|
# as of 2026-03-25 (xrt @ 481583d).
|
|
#
|
|
# Runtime note: this package only provides the userspace library. The
|
|
# kernel driver (amdxdna.ko) is a separate concern:
|
|
# • Linux >= 6.14 ships it in-tree (boot.kernelPackages.linux_latest).
|
|
# • Older kernels can use hardware.amdxdna.enable (once packaged).
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "xrt";
|
|
version = "2.19.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "Xilinx";
|
|
repo = "XRT";
|
|
rev = "481583db9a26cb506a37cab7f1881ae7c7de2f32";
|
|
hash = "sha256-WLZDjuuEGd3i77zXpAJkfQy/AszdSQ9pagy64yGX58Q=";
|
|
fetchSubmodules = false; # XRT submodules are Windows-only tools
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
cmake
|
|
ninja
|
|
pkg-config
|
|
python3
|
|
];
|
|
|
|
buildInputs = [
|
|
boost
|
|
curl
|
|
openssl
|
|
systemd # for libudev (device enumeration)
|
|
libdrm
|
|
ncurses
|
|
protobuf
|
|
elfutils # libelf
|
|
zlib
|
|
rapidjson
|
|
util-linux # libuuid
|
|
xz # liblzma
|
|
];
|
|
|
|
# XRT's CMakeLists.txt is in the src/ subdirectory.
|
|
cmakeDir = "src";
|
|
|
|
cmakeFlags = [
|
|
"-DCMAKE_BUILD_TYPE=Release"
|
|
"-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
|
|
# Build the NPU/XDNA variant (skips PCIe FPGA-specific components).
|
|
"-DXRT_NATIVE_BUILD=yes"
|
|
# Disable components we do not need:
|
|
"-DXRT_ENABLE_WERROR=OFF"
|
|
# Install libraries to lib/ (some builds default to lib64/).
|
|
"-DCMAKE_INSTALL_LIBDIR=lib"
|
|
];
|
|
|
|
# XRT's install target places a setup.sh in the prefix root; we don't need
|
|
# that for Nix — the binary wrapper / RPATH mechanism handles library lookup.
|
|
postInstall = ''
|
|
# Remove the CMake-generated setup.sh — not needed in a Nix env.
|
|
rm -f "$out"/setup.sh "$out"/setup.csh 2>/dev/null || true
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "AMD XRT (Xilinx Runtime) userspace library for XDNA NPUs";
|
|
longDescription = ''
|
|
XRT is the userspace component of AMD's XRT stack for their FPGA and
|
|
NPU devices. This package builds only the base library
|
|
(libxrt_coreutil, libxrt_core) that FastFlowLM links against to
|
|
communicate with the AMD XDNA 2 NPU via the amdxdna kernel driver.
|
|
|
|
The kernel driver (amdxdna.ko) is built in since Linux 6.14.
|
|
For older kernels it can be loaded via a DKMS package.
|
|
'';
|
|
homepage = "https://github.com/Xilinx/XRT";
|
|
license = licenses.asl20;
|
|
platforms = [ "x86_64-linux" ];
|
|
maintainers = [ ];
|
|
};
|
|
}
|