This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225{ buildFHSEnv, callPackage, lib, makeDesktopItem, runtimeShell, libfaketime, pkgsi686Linux, quartusSource, quartusOptions ? { devices = quartusSource.defaultDevices; # from quartusSource.devices e.g. "agilex3" installs = quartusSource.defaultInstalls; # from quartusSource.installers e.g. "QuestaSetup" }, unwrapped ? callPackage ./quartus-unwrapped.nix { inherit quartusSource quartusOptions; }, extraProfile ? "",}:
let installs = quartusOptions.installs or quartusSource.defaultInstalls;
withQuesta = lib.any (id: id == "QuestaSetup") ( lib.unique (installs ++ [ quartusSource.quartusInstaller ]) ); desktopItem = makeDesktopItem { name = "quartus-prime-${quartusSource.variant}"; exec = "quartus"; icon = "quartus"; desktopName = "Quartus"; genericName = "Quartus Prime"; categories = [ "Development" ]; }; # I think questa_fse/linux/vlm checksums itself, so use FHSUserEnv instead of `patchelf`inbuildFHSEnv rec { pname = "quartus-prime-${quartusSource.variant}"; # wrapped inherit (unwrapped) version;
targetPkgs = pkgs: [ (pkgs.runCommand "ld-lsb-compat" { } ( '' mkdir -p "$out/lib" ln -sr "${pkgs.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 pkgs.glib pkgs.libice pkgs.libsm pkgs.libxau pkgs.libxdmcp pkgs.libxscrnsaver pkgs.libudev0-shim pkgs.bzip2 pkgs.brotli pkgs.expat pkgs.dbus # qsys requirements pkgs.libxtst pkgs.libxi pkgs.dejavu_fonts pkgs.gnumake ];
# 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: let # This seems ugly - can we override `libpng = libpng12` for all `pkgs`? freetype = pkgs.freetype.override { libpng = pkgs.libpng12; }; fontconfig = pkgs.fontconfig.override { inherit freetype; }; libXft = pkgs.libxft.override { inherit freetype fontconfig; }; in [ # questa requirements pkgs.libxml2 pkgs.ncurses5 pkgs.unixodbc libXft # common requirements freetype fontconfig pkgs.libx11 pkgs.libxext pkgs.libxrender pkgs.libxcrypt-legacy ];
extraInstallCommands = '' mkdir -p $out/share/applications $out/share/icons/hicolor/64x64/apps ln -s ${desktopItem}/share/applications/* $out/share/applications ln -s ${unwrapped}/quartus/adm/quartusii.png $out/share/icons/hicolor/64x64/apps/quartus.png
progs_to_wrap=( "${unwrapped}"/quartus/bin/* "${unwrapped}"/quartus/sopc_builder/bin/qsys-{generate,edit,script} "${unwrapped}"/questa_fse/bin/* "${unwrapped}"/questa_fse/linux_x86_64/lmutil )
wrapper=$out/bin/${pname} progs_wrapped=() for prog in ''${progs_to_wrap[@]}; do relname="''${prog#"${unwrapped}/"}" bname="$(basename "$relname")" wrapped="$out/$relname" progs_wrapped+=("$wrapped") mkdir -p "$(dirname "$wrapped")" echo "#!${runtimeShell}" >> "$wrapped" NIXPKGS_QUARTUS_THIS_PROG_SUPPORTS_FIXED_CLOCK=1 case "$relname" in questa_fse/*) echo "export NIXPKGS_IS_QUESTA_WRAPPER=1" >> "$wrapped" # Any use of LD_PRELOAD breaks Questa, so disable the # SOURCE_DATE_EPOCH code path. NIXPKGS_QUARTUS_THIS_PROG_SUPPORTS_FIXED_CLOCK=0 ;; esac # SOURCE_DATE_EPOCH blocklist for programs that are known to hang/break # with fixed/static clock. case "$bname" in jtagd|quartus_pgm|quartus) NIXPKGS_QUARTUS_THIS_PROG_SUPPORTS_FIXED_CLOCK=0 ;; esac echo "export NIXPKGS_QUARTUS_THIS_PROG_SUPPORTS_FIXED_CLOCK=$NIXPKGS_QUARTUS_THIS_PROG_SUPPORTS_FIXED_CLOCK" >> "$wrapped" echo "exec $wrapper $prog \"\$@\"" >> "$wrapped" done
cd $out chmod +x ''${progs_wrapped[@]} # link into $out/bin so executables become available on $PATH ln --symbolic --relative --target-directory ./bin ''${progs_wrapped[@]} '';
profile = '' # LD_PRELOAD fixes issues in the licensing system that cause memory corruption and crashes when # starting most operations in many containerized environments, including WSL2, Docker, and LXC # (a similiar fix involving LD_PRELOADing tcmalloc did not solve the issue in my situation) # https://community.intel.com/t5/Intel-FPGA-Software-Installation/Running-Quartus-Prime-Standard-on-WSL-crashes-in-libudev-so/m-p/1189032 # # But, as can be seen in the above resource, LD_PRELOADing libudev breaks # compiling encrypted device libraries in Questa (with error # `(vlog-2163) Macro `<protected> is undefined.`), so only use LD_PRELOAD # for non-Questa wrappers. if [ "$NIXPKGS_IS_QUESTA_WRAPPER" != 1 ]; then export LD_PRELOAD=''${LD_PRELOAD:+$LD_PRELOAD:}/usr/lib/libudev.so.0 fi
# Implement the SOURCE_DATE_EPOCH specification for reproducible builds # (https://reproducible-builds.org/specs/quartusSource-date-epoch). # Require opt-in with NIXPKGS_QUARTUS_REPRODUCIBLE_BUILD=1 for now, in case # the blocklist is incomplete. if [ -n "$SOURCE_DATE_EPOCH" ] && [ "$NIXPKGS_QUARTUS_REPRODUCIBLE_BUILD" = 1 ] && [ "$NIXPKGS_QUARTUS_THIS_PROG_SUPPORTS_FIXED_CLOCK" = 1 ]; then export LD_LIBRARY_PATH="${ lib.makeLibraryPath [ libfaketime pkgsi686Linux.libfaketime ] }''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" export LD_PRELOAD=libfaketime.so.1''${LD_PRELOAD:+:$LD_PRELOAD} export FAKETIME_FMT="%s" export FAKETIME="$SOURCE_DATE_EPOCH" fi '' + extraProfile;
# Run the wrappers directly, instead of going via bash. runScript = "";
#passthru = { # inherit unwrapped; # tests = { # buildSof = runCommand "quartus-prime-lite-test-build-sof" # { nativeBuildInputs = [ quartus-prime-lite ]; # env.NIXPKGS_QUARTUS_REPRODUCIBLE_BUILD = "1"; # } # '' # cat >mydesign.vhd <<EOF # library ieee; # use ieee.std_logic_1164.all; # # entity mydesign is # port ( # in_0: in std_logic; # in_1: in std_logic; # out_1: out std_logic # ); # end mydesign; # # architecture dataflow of mydesign is # begin # out_1 <= in_0 and in_1; # end dataflow; # EOF # # quartus_sh --flow compile mydesign # # if ! [ -f mydesign.sof ]; then # echo "error: failed to produce mydesign.sof" >&2 # exit 1 # fi # # sha1sum mydesign.sof > "$out" # ''; # questaEncryptedModel = runCommand "quartus-prime-lite-test-questa-encrypted-model" # { env.NIXPKGS_QUARTUS_REPRODUCIBLE_BUILD = "1"; # } # '' # "${quartus-prime-lite}/bin/vlog" "${quartus-prime-lite.unwrapped}/questa_fse/intel/verilog/src/arriav_atoms_ncrypt.v" # touch "$out" # ''; # }; #};
inherit (unwrapped) meta;}