UPDATE the code discussed here is now in GitHub - nix-community/nix-environments: Repository to maintain out-of-tree shell.nix files (maintainer=@mic92)
I just wanted to drop this shell.nix
for installing xilinx vitis in case someone needs it:
{ pkgs ? import <nixpkgs> {} }:
let
xrt = pkgs.callPackage ./xrt.nix {};
fhs = pkgs.buildFHSUserEnv {
name = "xilinx-env";
targetPkgs = pkgs: with pkgs; [
bash
xrt
coreutils
zlib
stdenv.cc.cc
ncurses
xorg.libXext
xorg.libX11
xorg.libXrender
xorg.libXtst
xorg.libXi
xorg.libXft
xorg.libxcb
xorg.libxcb
# common requirements
freetype
fontconfig
glib
gtk2
gtk3
# from installLibs.sh
graphviz
gcc
unzip
nettools
];
multiPkgs = null;
profile = ''
vitis_dir=$(echo /opt/xilinx/Vitis/*/bin)
export PATH=$vitis_dir:$PATH
export XILINX_XRT="${xrt}"
'';
};
in fhs.env
and this xrt.nix
{ stdenv
, fetchFromGitHub
, linuxPackages_5_4
, cmake
, mesa
, libdrm
, pkg-config
, opencl-headers
, ocl-icd
, git
, boost
, ncurses
, openssl
, protobuf
, util-linux
, doxygen
, protobuf3_6
, valgrind
, python3Packages
, curl
, opencl-clhpp
, fetchurl
, libyaml
, udev
, dpkg
}:
let
inherit (linuxPackages_5_4) kernel;
suffix = "2.9.317";
version = "202020.${suffix}";
xrtBin = fetchurl {
url = "https://www.xilinx.com/bin/public/openDownload?filename=xrt_${version}_20.04-amd64-xrt.deb";
sha256 = "sha256-NTKjhOtTCFsjNweHOkH8CrM1ZloLM/+36NfM0w14l2Y=";
};
kernelMod = "$(pwd)/usr/src/xrt-${suffix}/driver/xocl";
KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
in stdenv.mkDerivation rec {
pname = "xrt";
inherit version;
src = fetchFromGitHub {
owner = "Xilinx";
repo = "XRT";
rev = version;
sha256 = "sha256-h9zpNHpm9Ys99wG2xdiXPHkzLkRgmM3Qk1PmQwiQv4c=";
};
enableParallelBuilding = true;
# we take the matter in our own hand
dontFixCmake = true;
buildInputs = [
libdrm
opencl-clhpp
opencl-headers
ocl-icd
boost
ncurses
openssl
protobuf3_6
util-linux
doxygen
curl
valgrind
python3Packages.sphinx
libyaml
udev
];
nativeBuildInputs = [
cmake
pkg-config
git
dpkg
];
NIX_CFLAGS_COMPILE = [ "-Wno-error" ];
preConfigure = ''
dpkg-deb -x ${xrtBin} root
export XRT_FIRMWARE_DIR=$(pwd)/root/lib/firmware/xilinx
if [ ! -d $XRT_FIRMWARE_DIR ]; then
echo "NO xrt firmware found in binary release"
false
fi
cd src
find . -type f -print0 | \
xargs -0 sed -i -e "s!/opt/xilinx!$out/opt/xilinx!;s!/lib/firmware!$out/lib/firmware!"
substituteInPlace CMakeLists.txt \
--replace "/usr" "$out/opt/xilinx"
find . -type f -iname "*.cmake" -print0 | \
xargs -0 sed -i -e "s!/usr/src/!$out/src/!;s!/etc/OpenCL!$out/etc/OpenCL!;s!/usr/share/pkgconfig!$out/lib/pkgconfig!"
'';
postInstall = ''
export INSTALL_MOD_PATH="$out"
modDir=$(echo $out/src/xrt-*/driver/xocl)
pushd $modDir/mgmtpf
make -C "${KERNELDIR}" -j$NIX_BUILD_CORES M=$(pwd)
make -C "${KERNELDIR}" -j$NIX_BUILD_CORES M=$(pwd) modules_install
popd
pushd $modDir/userpf
make -C "${KERNELDIR}" -j$NIX_BUILD_CORES M=$(pwd)
make -C "${KERNELDIR}" -j$NIX_BUILD_CORES M=$(pwd) modules_install
popd
ln -s $out/opt/xilinx/xrt/include $out/include
ln -s $out/opt/xilinx/xrt $out/include/xrt
ln -s $out/opt/xilinx/xrt/lib/* $out/lib
'';
meta = with stdenv.lib; {
description = "xilinx runtime library";
homepage = "https://www.xilinx.com/products/boards-and-kits/alveo/u50.html#gettingStarted";
license = licenses.mit;
maintainers = with maintainers; [ mic92 ];
platforms = [ "x86_64-linux" ];
};
}
Open a shell with it:
$ nix-shell shell.nix
and run the web installer downloaded from the xilinx website.
EDIT: the code above will be not regularly updated. But you can get a nix-shell for xilinx vitis by using this command:
nix develop --no-write-lock-file github:nix-community/nix-environments#xilinx-vitis