nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 98 lines 3.4 kB view raw
1# Saleae logic analyzer software 2# 3# Suggested udev rules to be able to access the Logic device without being root: 4# SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="0925", ATTR{idProduct}=="3881", MODE="0666" 5# SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="21a9", ATTR{idProduct}=="1001", MODE="0666" 6# 7# In NixOS, simply add this package to services.udev.packages. 8 9{ lib, stdenv, fetchurl, unzip, glib, libSM, libICE, gtk2, libXext, libXft 10, fontconfig, libXrender, libXfixes, libX11, libXi, libXrandr, libXcursor 11, freetype, libXinerama, libxcb, zlib, pciutils 12, makeDesktopItem, xkeyboardconfig, dbus, runtimeShell, libGL 13}: 14 15let 16 17 libPath = lib.makeLibraryPath [ 18 glib libSM libICE gtk2 libXext libXft fontconfig libXrender libXfixes libX11 19 libXi libXrandr libXcursor freetype libXinerama libxcb zlib stdenv.cc.cc.lib 20 dbus libGL 21 ]; 22 23in 24 25assert stdenv.hostPlatform.system == "x86_64-linux"; 26 27stdenv.mkDerivation rec { 28 pname = "saleae-logic"; 29 version = "1.2.18"; 30 31 src = fetchurl { 32 name = "saleae-logic-${version}-64bit.zip"; 33 url = "http://downloads.saleae.com/logic/${version}/Logic%20${version}%20(64-bit).zip"; 34 sha256 = "0lhair2vsg8sjvzicvfcjfmvy30q7i01xj4z02iqh7pgzpb025h8"; 35 }; 36 37 desktopItem = makeDesktopItem { 38 name = "saleae-logic"; 39 exec = "saleae-logic"; 40 icon = ""; # the package contains no icon 41 comment = "Software for Saleae logic analyzers"; 42 desktopName = "Saleae Logic"; 43 genericName = "Logic analyzer"; 44 categories = [ "Development" ]; 45 }; 46 47 nativeBuildInputs = [ unzip ]; 48 49 installPhase = '' 50 # Copy prebuilt app to $out 51 mkdir "$out" 52 cp -r * "$out" 53 54 # Patch it 55 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$out/Logic" 56 for bin in "$out/Logic" \ 57 "$out/libQt5Widgets.so.5" \ 58 "$out/libQt5Gui.so.5" \ 59 "$out/libQt5Core.so.5" \ 60 "$out/libQt5Network.so.5" ; do 61 patchelf --set-rpath "${stdenv.cc.cc.lib}/lib:${stdenv.cc.cc.lib}/lib64:${libPath}:\$ORIGIN/Analyzers:\$ORIGIN" "$bin" 62 done 63 64 patchelf --set-rpath "${stdenv.cc.cc.lib}/lib:${stdenv.cc.cc.lib}/lib64:${libPath}:\$ORIGIN/../" "$out/platforms/libqxcb.so" 65 66 # Build the LD_PRELOAD library that makes Logic work from a read-only directory 67 mkdir -p "$out/lib" 68 gcc -shared -fPIC -DOUT=\"$out\" "${./preload.c}" -o "$out/lib/preload.so" -ldl 69 70 # Make wrapper script that uses the LD_PRELOAD library 71 mkdir -p "$out/bin" 72 cat > "$out/bin/saleae-logic" << EOF 73 #!${runtimeShell} 74 export LD_PRELOAD="$out/lib/preload.so" 75 export QT_XKB_CONFIG_ROOT="${xkeyboardconfig}/share/X11/xkb" 76 export PATH="${pciutils}/bin:\$PATH" 77 exec "$out/Logic" "\$@" 78 EOF 79 chmod a+x "$out"/bin/saleae-logic 80 81 # Copy the generated .desktop file 82 mkdir -p "$out/share/applications" 83 cp "$desktopItem"/share/applications/* "$out/share/applications/" 84 85 # Install provided udev rules 86 mkdir -p "$out/etc/udev/rules.d" 87 cp Drivers/99-SaleaeLogic.rules "$out/etc/udev/rules.d/" 88 ''; 89 90 meta = with lib; { 91 description = "Software for Saleae logic analyzers"; 92 homepage = "https://www.saleae.com/"; 93 sourceProvenance = with sourceTypes; [ binaryNativeCode ]; 94 license = licenses.unfree; 95 platforms = platforms.linux; 96 maintainers = [ maintainers.bjornfor ]; 97 }; 98}