quartus-prime-lite: add option to disable Questa simulator

Saves ~5GB of closure size and eliminates dependency on 32 bit
libraries.
This commit is contained in:
Thomas Watson 2024-04-06 16:07:35 -05:00 committed by Bjørn Forsman
parent 4d46279ad9
commit 0355aaa7d2
2 changed files with 23 additions and 20 deletions

View file

@ -1,5 +1,6 @@
{ lib, buildFHSEnv, callPackage, makeDesktopItem, writeScript, runtimeShell
, runCommand, unstick, quartus-prime-lite
, withQuesta ? true
, supportedDevices ? [ "Arria II" "Cyclone V" "Cyclone IV" "Cyclone 10 LP" "MAX II/V" "MAX 10 FPGA" ]
, unwrapped ? callPackage ./quartus.nix { inherit unstick supportedDevices withQuesta; }
}:
@ -18,11 +19,12 @@ in buildFHSEnv rec {
name = "quartus-prime-lite"; # wrapped
targetPkgs = pkgs: with pkgs; [
(runCommand "ld-lsb-compat" {} ''
(runCommand "ld-lsb-compat" {} (''
mkdir -p "$out/lib"
ln -sr "${glibc}/lib/ld-linux-x86-64.so.2" "$out/lib/ld-lsb-x86-64.so.3"
'' + lib.optionalString withQuesta ''
ln -sr "${pkgsi686Linux.glibc}/lib/ld-linux.so.2" "$out/lib/ld-lsb.so.3"
'')
''))
# quartus requirements
glib
xorg.libICE
@ -41,9 +43,10 @@ in buildFHSEnv rec {
gnumake
];
# Also support 32-bit executables.
multiArch = true;
# Also support 32-bit executables used by simulator.
multiArch = withQuesta;
# these libs are installed as 64 bit, plus as 32 bit when multiArch is true
multiPkgs = pkgs: with pkgs; let
# This seems ugly - can we override `libpng = libpng12` for all `pkgs`?
freetype = pkgs.freetype.override { libpng = libpng12; };

View file

@ -1,4 +1,5 @@
{ stdenv, lib, unstick, fetchurl
, withQuesta ? true
, supportedDevices ? [ "Arria II" "Cyclone V" "Cyclone IV" "Cyclone 10 LP" "MAX II/V" "MAX 10 FPGA" ]
}:
@ -41,26 +42,25 @@ let
url = "https://downloads.intel.com/akdlm/software/acdsinst/${lib.versions.majorMinor version}std/${lib.elemAt (lib.splitVersion version) 4}/ib_installers/${name}";
};
installers = map download ([{
name = "QuartusLiteSetup-${version}-linux.run";
sha256 = "1mg4db56rg407kdsvpzys96z59bls8djyddfzxi6bdikcklxz98h";
}] ++ lib.optional withQuesta {
name = "QuestaSetup-${version}-linux.run";
sha256 = "0f9lyphk4vf4ijif3kb4iqf18jl357z9h8g16kwnzaqwfngh2ixk";
});
components = map (id: download {
name = "${id}-${version}.qdz";
sha256 = lib.getAttr id componentHashes;
}) (lib.attrValues supportedDeviceIds);
in stdenv.mkDerivation rec {
inherit version;
pname = "quartus-prime-lite-unwrapped";
src = map download ([{
name = "QuartusLiteSetup-${version}-linux.run";
sha256 = "1mg4db56rg407kdsvpzys96z59bls8djyddfzxi6bdikcklxz98h";
} {
name = "QuestaSetup-${version}-linux.run";
sha256 = "0f9lyphk4vf4ijif3kb4iqf18jl357z9h8g16kwnzaqwfngh2ixk";
}] ++ (map (id: {
name = "${id}-${version}.qdz";
sha256 = lib.getAttr id componentHashes;
}) (lib.attrValues supportedDeviceIds)));
nativeBuildInputs = [ unstick ];
buildCommand = let
installers = lib.sublist 0 2 src;
components = lib.sublist 2 ((lib.length src) - 2) src;
copyInstaller = installer: ''
# `$(cat $NIX_CC/nix-support/dynamic-linker) $src[0]` often segfaults, so cp + patchelf
cp ${installer} $TEMP/${installer.name}
@ -68,13 +68,13 @@ in stdenv.mkDerivation rec {
patchelf --interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $TEMP/${installer.name}
'';
copyComponent = component: "cp ${component} $TEMP/${component.name}";
# leaves enabled: quartus, questa_fse, devinfo
# leaves enabled: quartus, devinfo
disabledComponents = [
"quartus_help"
"quartus_update"
# not questa_fse
"questa_fe"
] ++ (lib.attrValues unsupportedDeviceIds);
] ++ (lib.optional (!withQuesta) "questa_fse")
++ (lib.attrValues unsupportedDeviceIds);
in ''
echo "setting up installer..."
${lib.concatMapStringsSep "\n" copyInstaller installers}