Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vivado: init at 2017.2 #93436

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
150 changes: 150 additions & 0 deletions pkgs/applications/science/electronics/vivado/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{ stdenv
, lib
, coreutils
, fetchurl
, patchelf
, procps
, makeWrapper
, requireFile
, ncurses5
, zlib
, libuuid
, libSM
, libICE
, libX11
, libXrender
, libxcb
, libXext
, libXtst
, libXi
, glib
, freetype
, gtk2
}:

stdenv.mkDerivation rec {
pname = "vivado";
version = "2017.2";

matthuszagh marked this conversation as resolved.
Show resolved Hide resolved
# requireFile prevents rehashing each time, which saves time during
# rebuilds.
src = requireFile rec {
name = "Xilinx_Vivado_SDK_2017.2_0616_1.tar.gz";
message = ''
This nix expression requires that ${name} is already part of the store.
Login to Xilinx, download from
https://www.xilinx.com/support/download.html,
rename the file to ${name}, and add it to the nix store with
"nix-prefetch-url file:///path/to/${name}".
'';
sha256 = "06pb4wjz76wlwhhzky9vkyi4aq6775k63c2kw3j9prqdipxqzf9j";
};
Comment on lines +29 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the requireFile arguments (name and sha256) arguments with default values to the derivation (i.e. after line 21)? That'll make it a bit easier for people to upgrade on their own (with vivado.override { name = "..."; sha256 = "..."; } rather than making an overlay) after Xilinx releases new versions that haven't been hashed/submitted here yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@9999years definitely. The only thing is I can't guarantee the builder will work for anything other than this version. For instance, the builder failed for 2019.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with vivado.override { name = "..."; sha256 = "..."; } rather than making an overlay

For instance, the builder failed for 2019.

Than we should not add this and let people overwrite it with overwriteAttr


nativeBuildInputs = [
makeWrapper
];

buildInputs = [
procps
ncurses5
];

postPatch = ''
patchShebangs xsetup

patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
tps/lnx64/jre/bin/java

sed -i -- 's|/bin/rm|rm|g' xsetup
'';

dontBuild = true;

installPhase = ''
cat <<EOF > install_config.txt
Edition=Vivado HL WebPACK
Destination=$out/opt
Modules=Software Development Kit (SDK):1,DocNav:0,Kintex UltraScale:0,Zynq-7000:1,System Generator for DSP:0,Artix-7:1,Kintex-7:0
InstallOptions=Acquire or Manage a License Key:0,Enable WebTalk for SDK to send usage statistics to Xilinx:0
CreateProgramGroupShortcuts=0
ProgramGroupFolder=Xilinx Design Tools
CreateShortcutsForAllUsers=0
CreateDesktopShortcuts=0
CreateFileAssociation=0
EOF

mkdir -p $out/opt

# The installer will be killed as soon as it says that post install tasks have failed.
# This is required because it tries to run the unpatched scripts to check if the installation
# has succeeded. However, these scripts will fail because they have not been patched yet,
# and the installer will proceed to delete the installation if not killed.
(./xsetup --agree 3rdPartyEULA,WebTalkTerms,XilinxEULA --batch Install --config install_config.txt || true) | while read line
do
[[ "''${line}" == *"Execution of Pre/Post Installation Tasks Failed"* ]] && echo "killing installer!" && ((pkill -9 -f "tps/lnx64/jre/bin/java") || true)
echo ''${line}
done
'';

libPath = lib.makeLibraryPath [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this into a let in to postFixup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get an error when I try to run vivado after doing this: application-specific initialization failed: couldn't load file "librdi_commontasks.so": libtinfo.so.5: cannot open shared object file: No such file or directory. It works if I keep it out of the let though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is because your are using bash variables instead of nix ones in preFixup. Please use nix variables there.

stdenv.cc.cc
ncurses5
zlib
libuuid
libSM
libICE
libX11
libXrender
libxcb
libXext
libXtst
libXi
glib
freetype
gtk2
];

preFixup = ''
# Patch installed files
patchShebangs $out/opt/Vivado/$version/bin
patchShebangs $out/opt/SDK/$version/bin
Comment on lines +108 to +110
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Patch installed files
patchShebangs $out/opt/Vivado/$version/bin
patchShebangs $out/opt/SDK/$version/bin
patchShebangs $out/opt/{Vivado,SDK}/$version/bin


# Hack around lack of libtinfo in NixOS
ln -s $ncurses/lib/libncursesw.so.6 $out/opt/Vivado/$version/lib/lnx64.o/libtinfo.so.5
ln -s $ncurses/lib/libncursesw.so.6 $out/opt/SDK/$version/lib/lnx64.o/libtinfo.so.5
Comment on lines +112 to +114
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change that name with patchelf which is a bit cleaner


# Patch ELFs
for f in $out/opt/Vivado/$version/bin/unwrapped/lnx64.o/*
do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $f || true
done
for f in $out/opt/SDK/$version/bin/unwrapped/lnx64.o/*
do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $f || true
done
Comment on lines +116 to +124
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Patch ELFs
for f in $out/opt/Vivado/$version/bin/unwrapped/lnx64.o/*
do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $f || true
done
for f in $out/opt/SDK/$version/bin/unwrapped/lnx64.o/*
do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $f || true
done
# Patch ELFs
for f in $out/opt/Vivado/$version/bin/unwrapped/lnx64.o/*; do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $f
done
for f in $out/opt/SDK/$version/bin/unwrapped/lnx64.o/*; do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $f
done

the build should fail if patchelf fails

patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/opt/SDK/$version/eclipse/lnx64.o/eclipse
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/opt/SDK/$version/tps/lnx64/jre/bin/java

wrapProgram $out/opt/Vivado/$version/bin/vivado --prefix LD_LIBRARY_PATH : "$libPath"
wrapProgram $out/opt/SDK/$version/bin/xsdk --prefix LD_LIBRARY_PATH : "$libPath"
wrapProgram $out/opt/SDK/$version/eclipse/lnx64.o/eclipse --prefix LD_LIBRARY_PATH : "$libPath"
wrapProgram $out/opt/SDK/$version/tps/lnx64/jre/bin/java --prefix LD_LIBRARY_PATH : "$libPath"
Comment on lines +128 to +131
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
wrapProgram $out/opt/Vivado/$version/bin/vivado --prefix LD_LIBRARY_PATH : "$libPath"
wrapProgram $out/opt/SDK/$version/bin/xsdk --prefix LD_LIBRARY_PATH : "$libPath"
wrapProgram $out/opt/SDK/$version/eclipse/lnx64.o/eclipse --prefix LD_LIBRARY_PATH : "$libPath"
wrapProgram $out/opt/SDK/$version/tps/lnx64/jre/bin/java --prefix LD_LIBRARY_PATH : "$libPath"
for file in $out/opt/Vivado/$version/bin/vivado $out/opt/SDK/$version/bin/xsdk $out/opt/SDK/$version/eclipse/lnx64.o/eclipse $out/opt/SDK/$version/tps/lnx64/jre/bin/java ; do
wrapProgram $file --prefix LD_LIBRARY_PATH : "$libPath"
done


# wrapProgram on its own will not work because of the way the Vivado script runs ./launch
# Therefore, we need Even More Patches...
sed -i -- 's|`basename "\$0"`|vivado|g' $out/opt/Vivado/$version/bin/.vivado-wrapped
sed -i -- 's|`basename "\$0"`|xsdk|g' $out/opt/SDK/$version/bin/.xsdk-wrapped

# Add vivado and xsdk to bin folder
mkdir $out/bin
ln -s $out/opt/Vivado/$version/bin/vivado $out/bin/vivado
ln -s $out/opt/SDK/$version/bin/xsdk $out/bin/xsdk
'';

meta = with lib; {
description = "Xilinx Vivado";
homepage = "https://www.xilinx.com/products/design-tools/vivado.html";
license = licenses.unfree;
maintainers = with maintainers; [ matthuszagh ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12636,6 +12636,8 @@ with pkgs;

viu = callPackage ../tools/graphics/viu { };

vivado = callPackage ../applications/science/electronics/vivado { };

vix = callPackage ../tools/misc/vix { };

vkBasalt = callPackage ../tools/graphics/vkBasalt {
Expand Down