Unverified Commit 5046a3a4 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

ltspice: init at 24.1.10 (#453532)

parents ec4b2f26 7942113f
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

# Original Authors: fenugrec <fenugrec users sourceforge net> and Max Stabel <max dot stabel03 at gmail dot com>

CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/ltspice"

if [[ ! -d $CONFIG_DIR ]]; then
   mkdir -p "$CONFIG_DIR"
fi
if [[ ! -f "$CONFIG_DIR/LTspice.ini" ]]; then
   # disable sending telemetry
   echo -e "[Options]\nCaptureAnalytics=false" > "$CONFIG_DIR/LTspice.ini"
fi

WINEPREFIX="${WINEPREFIX-"${XDG_DATA_HOME-"$HOME/.local/share"}"/ltspice}"
if [[ ! -d $WINEPREFIX ]]; then
   mkdir -p "$WINEPREFIX"
fi
WINEARCH=win64 WINEPREFIX=$WINEPREFIX WINEDLLOVERRIDES=winemenubuilder.exe=d wine start.exe /unix @outpath@/libexec/ltspice/LTspice.exe -ini $CONFIG_DIR/LTspice.ini "$@"
+91 −0
Original line number Diff line number Diff line
{
  lib,
  stdenvNoCC,
  fetchurl,
  msitools,
  icoutils,
  imagemagick,
  wine64,
  makeDesktopItem,
  copyDesktopItems,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "ltspice";
  version = "24.1.10";
  src = fetchurl {
    url = "https://web.archive.org/web/20251028221949/https://ltspice.analog.com/software/LTspice64.msi";
    hash = "sha256-LSK84ogbBk9kP7LKg8rzCGDqq36XfsK4Kzn2Zwea8C4=";
  };
  dontUnpack = true;
  dontConfigure = true;

  nativeBuildInputs = [
    msitools
    icoutils
    imagemagick
    copyDesktopItems
  ];

  postPatch = ''
    cp ${./ltspice.sh} ./ltspice.sh
    substituteInPlace ./ltspice.sh \
      --replace-fail wine ${lib.getExe wine64} \
      --replace-fail @outpath@ $out
  '';

  buildPhase = ''
    runHook preBuild
    msiextract $src
    mv -f "APPDIR:."/* .
    mv -f "LocalAppDataFolder/LTspice"/* .
    wrestool -x -t 14 LTspice.exe | magick ICO:- ltspice.png
    rm Remove.exe updater.exe
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out
    install -Dm644 ltspice.png $out/share/pixmaps/ltspice.png

    install -m755 -d $out/libexec/ltspice
    install -m755 *.exe $out/libexec/ltspice
    install -m655 *.zip $out/libexec/ltspice

    install -Dm755 ltspice.sh $out/bin/ltspice
    runHook postInstall
  '';
  desktopItems = [
    (makeDesktopItem {
      name = "ltspice";
      desktopName = "LTspice";
      comment = finalAttrs.meta.description;
      exec = "${finalAttrs.meta.mainProgram} %f";
      icon = "ltspice";
      mimeTypes = [
        "application/raw"
        "application/asc"
        "application/res"
        "application/asy"
        "application/bead"
        "application/bjt"
        "application/cap"
        "application/dio"
        "application/ind"
        "application/jft"
        "application/mos"
      ];
    })
  ];

  meta = {
    description = "SPICE simulator, schematic capture and waveform viewer";
    homepage = "https://www.analog.com/en/resources/design-tools-and-calculators/ltspice-simulator.html";
    license = lib.licenses.unfree;
    mainProgram = "ltspice";
    maintainers = [ lib.maintainers.zimward ];
    #technically windows too, but for that the builder would need some conditionals
    platforms = [ "x86_64-linux" ];
    sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
  };
})