diff options
Diffstat (limited to 'pkgs/applications/editors')
-rw-r--r-- | pkgs/applications/editors/quartus-prime/default.nix | 97 | ||||
-rw-r--r-- | pkgs/applications/editors/typora/default.nix | 104 |
2 files changed, 168 insertions, 33 deletions
diff --git a/pkgs/applications/editors/quartus-prime/default.nix b/pkgs/applications/editors/quartus-prime/default.nix index a3eee45ed4d0..d68925e752f4 100644 --- a/pkgs/applications/editors/quartus-prime/default.nix +++ b/pkgs/applications/editors/quartus-prime/default.nix @@ -1,4 +1,5 @@ -{ stdenv, lib, buildFHSEnvChroot, callPackage, makeDesktopItem, writeScript +{ lib, buildFHSEnv, callPackage, makeDesktopItem, writeScript, runtimeShell +, runCommand, quartus-prime-lite , supportedDevices ? [ "Arria II" "Cyclone V" "Cyclone IV" "Cyclone 10 LP" "MAX II/V" "MAX 10 FPGA" ] , unwrapped ? callPackage ./quartus.nix { inherit supportedDevices; } }: @@ -13,10 +14,15 @@ let categories = [ "Development" ]; }; # I think modelsim_ase/linux/vlm checksums itself, so use FHSUserEnv instead of `patchelf` -in buildFHSEnvChroot rec { +in buildFHSEnv rec { name = "quartus-prime-lite"; # wrapped targetPkgs = pkgs: with pkgs; [ + (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" + ln -sr "${pkgsi686Linux.glibc}/lib/ld-linux.so.2" "$out/lib/ld-lsb.so.3" + '') # quartus requirements glib xorg.libICE @@ -26,6 +32,10 @@ in buildFHSEnvChroot rec { xorg.libXtst xorg.libXi ]; + + # Also support 32-bit executables. + multiArch = true; + multiPkgs = pkgs: with pkgs; let # This seems ugly - can we override `libpng = libpng12` for all `pkgs`? freetype = pkgs.freetype.override { libpng = libpng12; }; @@ -47,46 +57,67 @@ in buildFHSEnvChroot rec { libxcrypt-legacy ]; - passthru = { inherit unwrapped; }; - - extraInstallCommands = let - quartusExecutables = (map (c: "quartus/bin/quartus_${c}") [ - "asm" "cdb" "cpf" "drc" "eda" "fit" "jbcc" "jli" "map" "pgm" "pow" - "sh" "si" "sim" "sta" "stp" "tan" - ]) ++ [ "quartus/bin/quartus" ]; - - qsysExecutables = map (c: "quartus/sopc_builder/bin/qsys-${c}") [ - "generate" "edit" "script" - ]; - # Should we install all executables ? - modelsimExecutables = map (c: "modelsim_ase/bin/${c}") [ - "vsim" "vlog" "vlib" - ]; - in '' + extraInstallCommands = '' mkdir -p $out/share/applications $out/share/icons/128x128 ln -s ${desktopItem}/share/applications/* $out/share/applications ln -s ${unwrapped}/licenses/images/dc_quartus_panel_logo.png $out/share/icons/128x128/quartus.png - mkdir -p $out/quartus/bin $out/quartus/sopc_builder/bin $out/modelsim_ase/bin - WRAPPER=$out/bin/${name} - EXECUTABLES="${lib.concatStringsSep " " (quartusExecutables ++ qsysExecutables ++ modelsimExecutables)}" - for executable in $EXECUTABLES; do - echo "#!${stdenv.shell}" >> $out/$executable - echo "$WRAPPER ${unwrapped}/$executable \"\$@\"" >> $out/$executable + progs_to_wrap=( + "${unwrapped}"/quartus/bin/* + "${unwrapped}"/quartus/sopc_builder/bin/qsys-{generate,edit,script} + # Should we install all executables? + "${unwrapped}"/modelsim_ase/bin/{vsim,vlog,vlib,vcom,vdel,vmap} + "${unwrapped}"/modelsim_ase/linuxaloem/lmutil + ) + + wrapper=$out/bin/${name} + progs_wrapped=() + for prog in ''${progs_to_wrap[@]}; do + relname="''${prog#"${unwrapped}/"}" + wrapped="$out/$relname" + progs_wrapped+=("$wrapped") + mkdir -p "$(dirname "$wrapped")" + echo "#!${runtimeShell}" >> "$wrapped" + case "$relname" in + modelsim_ase/*) + echo "export NIXPKGS_IS_MODELSIM_WRAPPER=1" >> "$wrapped" + ;; + esac + echo "$wrapper $prog \"\$@\"" >> "$wrapped" done cd $out - chmod +x $EXECUTABLES + chmod +x ''${progs_wrapped[@]} # link into $out/bin so executables become available on $PATH - ln --symbolic --relative --target-directory ./bin $EXECUTABLES + ln --symbolic --relative --target-directory ./bin ''${progs_wrapped[@]} ''; - # 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) - # we use the name so that quartus can load the 64 bit verson and modelsim can load the 32 bit version - # https://community.intel.com/t5/Intel-FPGA-Software-Installation/Running-Quartus-Prime-Standard-on-WSL-crashes-in-libudev-so/m-p/1189032 - runScript = writeScript "${name}-wrapper" '' - exec env LD_PRELOAD=libudev.so.0 "$@" + 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) + # we use the name so that quartus can load the 64 bit verson and modelsim can load the 32 bit version + # 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 ModelSim (with error + # `(vlog-2163) Macro `<protected> is undefined.`), so only use LD_PRELOAD + # for non-ModelSim wrappers. + if [ "$NIXPKGS_IS_MODELSIM_WRAPPER" != 1 ]; then + export LD_PRELOAD=''${LD_PRELOAD:+$LD_PRELOAD:}libudev.so.0 + fi ''; + + # Run the wrappers directly, instead of going via bash. + runScript = ""; + + passthru = { + inherit unwrapped; + tests = { + modelsimEncryptedModel = runCommand "quartus-prime-lite-test-modelsim-encrypted-model" {} '' + "${quartus-prime-lite}/bin/vlog" "${quartus-prime-lite.unwrapped}/modelsim_ase/altera/verilog/src/arriav_atoms_ncrypt.v" + touch "$out" + ''; + }; + }; } diff --git a/pkgs/applications/editors/typora/default.nix b/pkgs/applications/editors/typora/default.nix new file mode 100644 index 000000000000..5332e0b5d05b --- /dev/null +++ b/pkgs/applications/editors/typora/default.nix @@ -0,0 +1,104 @@ +{ stdenv +, fetchurl +, dpkg +, lib +, glib +, nss +, nspr +, at-spi2-atk +, cups +, dbus +, libdrm +, gtk3 +, pango +, cairo +, xorg +, libxkbcommon +, mesa +, expat +, alsa-lib +, buildFHSEnv +}: + +let + pname = "typora"; + version = "1.7.5"; + src = fetchurl { + url = "https://download.typora.io/linux/typora_${version}_amd64.deb"; + hash = "sha256-4Q+fx1kNu98+nxnI/7hLhE6zOdNsaAiAnW6xVd+hZOI="; + }; + + typoraBase = stdenv.mkDerivation { + inherit pname version src; + + nativeBuildInputs = [ dpkg ]; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin $out/share + mv usr/share $out + ln -s $out/share/typora/Typora $out/bin/Typora + runHook postInstall + ''; + }; + + typoraFHS = buildFHSEnv { + name = "typora-fhs"; + targetPkgs = pkgs: (with pkgs; [ + typoraBase + udev + alsa-lib + glib + nss + nspr + atk + cups + dbus + gtk3 + libdrm + pango + cairo + mesa + expat + libxkbcommon + ]) ++ (with pkgs.xorg; [ + libX11 + libXcursor + libXrandr + libXcomposite + libXdamage + libXext + libXfixes + libxcb + ]); + runScript = '' + Typora $* + ''; + }; + +in stdenv.mkDerivation { + inherit pname version; + + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + mkdir -p $out/bin + ln -s ${typoraFHS}/bin/typora-fhs $out/bin/typora + ln -s ${typoraBase}/share/ $out + runHook postInstall + ''; + + meta = with lib; { + description = "A markdown editor, a markdown reader"; + homepage = "https://typora.io/"; + license = licenses.unfree; + maintainers = with maintainers; [ npulidomateo ]; + platforms = [ "x86_64-linux" ]; + }; +} |