1 # Saleae logic analyzer software
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"
7 # In NixOS, simply add this package to services.udev.packages.
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
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
25 assert stdenv.hostPlatform.system == "x86_64-linux";
27 stdenv.mkDerivation rec {
28 pname = "saleae-logic";
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";
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" ];
47 nativeBuildInputs = [ unzip ];
50 # Copy prebuilt app to $out
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 "${lib.getLib stdenv.cc.cc}/lib:${lib.getLib stdenv.cc.cc}/lib64:${libPath}:\$ORIGIN/Analyzers:\$ORIGIN" "$bin"
64 patchelf --set-rpath "${lib.getLib stdenv.cc.cc}/lib:${lib.getLib stdenv.cc.cc}/lib64:${libPath}:\$ORIGIN/../" "$out/platforms/libqxcb.so"
66 # Build the LD_PRELOAD library that makes Logic work from a read-only directory
68 gcc -shared -fPIC -DOUT=\"$out\" "${./preload.c}" -o "$out/lib/preload.so" -ldl
70 # Make wrapper script that uses the LD_PRELOAD library
72 cat > "$out/bin/saleae-logic" << EOF
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" "\$@"
79 chmod a+x "$out"/bin/saleae-logic
81 # Copy the generated .desktop file
82 mkdir -p "$out/share/applications"
83 cp "$desktopItem"/share/applications/* "$out/share/applications/"
85 # Install provided udev rules
86 mkdir -p "$out/etc/udev/rules.d"
87 cp Drivers/99-SaleaeLogic.rules "$out/etc/udev/rules.d/"
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 ];