nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 138 lines 4.2 kB view raw
1{ 2 stdenv, 3 lib, 4 unstick, 5 fetchurl, 6 withQuesta ? true, 7 supportedDevices ? [ 8 "Arria II" 9 "Cyclone V" 10 "Cyclone IV" 11 "Cyclone 10 LP" 12 "MAX II/V" 13 "MAX 10 FPGA" 14 ], 15}: 16 17let 18 deviceIds = { 19 "Arria II" = "arria_lite"; 20 "Cyclone V" = "cyclonev"; 21 "Cyclone IV" = "cyclone"; 22 "Cyclone 10 LP" = "cyclone10lp"; 23 "MAX II/V" = "max"; 24 "MAX 10 FPGA" = "max10"; 25 }; 26 27 supportedDeviceIds = 28 assert lib.assertMsg (lib.all ( 29 name: lib.hasAttr name deviceIds 30 ) supportedDevices) "Supported devices are: ${lib.concatStringsSep ", " (lib.attrNames deviceIds)}"; 31 lib.listToAttrs ( 32 map (name: { 33 inherit name; 34 value = deviceIds.${name}; 35 }) supportedDevices 36 ); 37 38 unsupportedDeviceIds = lib.filterAttrs ( 39 name: value: !(lib.hasAttr name supportedDeviceIds) 40 ) deviceIds; 41 42 componentHashes = { 43 "arria_lite" = "sha256-PNoc15Y5h+2bxhYFIxkg1qVAsXIX3IMfEQSdPLVNUp4="; 44 "cyclone" = "sha256-2huDuTkXt6jszwih0wzusoxRvECi6+tupvRcUvn6eIA="; 45 "cyclone10lp" = "sha256-i8VJKqlIfQmK2GWhm0W0FujHcup4RjeXughL2VG5gkY="; 46 "cyclonev" = "sha256-HoNJkcD96rPQEZtjbtmiRpoKh8oni7gOLVi80c1a3TM="; 47 "max" = "sha256-qh920mvu0H+fUuSJBH7fDPywzll6sGdmEtfx32ApCSA="; 48 "max10" = "sha256-XOyreAG3lYEV7Mnyh/UnFTuOwPQsd/t23Q8/P2p6U+0="; 49 }; 50 51 version = "23.1std.1.993"; 52 53 download = 54 { name, sha256 }: 55 fetchurl { 56 inherit name sha256; 57 # e.g. "23.1std.1.993" -> "23.1std/993" 58 url = "https://downloads.intel.com/akdlm/software/acdsinst/${lib.versions.majorMinor version}std/${lib.elemAt (lib.splitVersion version) 4}/ib_installers/${name}"; 59 }; 60 61 installers = map download ( 62 [ 63 { 64 name = "QuartusLiteSetup-${version}-linux.run"; 65 sha256 = "sha256-OCp2hZrfrfp1nASuVNWgg8/ODRrl67SJ+c6IWq5eWvY="; 66 } 67 ] 68 ++ lib.optional withQuesta { 69 name = "QuestaSetup-${version}-linux.run"; 70 sha256 = "sha256-Dne4MLFSGXUVLMd+JgiS/d5RX9t5gs6PEvexTssLdF4="; 71 } 72 ); 73 components = map ( 74 id: 75 download { 76 name = "${id}-${version}.qdz"; 77 sha256 = lib.getAttr id componentHashes; 78 } 79 ) (lib.attrValues supportedDeviceIds); 80 81in 82stdenv.mkDerivation { 83 inherit version; 84 pname = "quartus-prime-lite-unwrapped"; 85 86 nativeBuildInputs = [ unstick ]; 87 88 buildCommand = 89 let 90 copyInstaller = installer: '' 91 # `$(cat $NIX_CC/nix-support/dynamic-linker) $src[0]` often segfaults, so cp + patchelf 92 cp ${installer} $TEMP/${installer.name} 93 chmod u+w,+x $TEMP/${installer.name} 94 patchelf --interpreter $(cat $NIX_CC/nix-support/dynamic-linker) $TEMP/${installer.name} 95 ''; 96 copyComponent = component: "cp ${component} $TEMP/${component.name}"; 97 # leaves enabled: quartus, devinfo 98 disabledComponents = [ 99 "quartus_help" 100 "quartus_update" 101 "questa_fe" 102 ] 103 ++ (lib.optional (!withQuesta) "questa_fse") 104 ++ (lib.attrValues unsupportedDeviceIds); 105 in 106 '' 107 echo "setting up installer..." 108 ${lib.concatMapStringsSep "\n" copyInstaller installers} 109 ${lib.concatMapStringsSep "\n" copyComponent components} 110 111 echo "executing installer..." 112 # "Could not load seccomp program: Invalid argument" might occur if unstick 113 # itself is compiled for x86_64 instead of the non-x86 host. In that case, 114 # override the input. 115 unstick $TEMP/${(builtins.head installers).name} \ 116 --disable-components ${lib.concatStringsSep "," disabledComponents} \ 117 --mode unattended --installdir $out --accept_eula 1 118 119 echo "cleaning up..." 120 rm -r $out/uninstall $out/logs 121 122 # replace /proc pentium check with a true statement. this allows usage under emulation. 123 substituteInPlace $out/quartus/adm/qenv.sh \ 124 --replace-fail 'grep sse /proc/cpuinfo > /dev/null 2>&1' ':' 125 ''; 126 127 meta = with lib; { 128 homepage = "https://fpgasoftware.intel.com"; 129 description = "FPGA design and simulation software"; 130 sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 131 license = licenses.unfree; 132 platforms = [ "x86_64-linux" ]; 133 maintainers = with maintainers; [ 134 bjornfor 135 kwohlfahrt 136 ]; 137 }; 138}