From e2d7e5ac7f33ea3c2a2c18fe5d0820d671a97b2c Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Thu, 17 Jun 2021 15:42:58 -0400 Subject: [PATCH] packettracer: init --- flake.nix | 1 + pkgs/packettracer/default.nix | 110 ++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 pkgs/packettracer/default.nix diff --git a/flake.nix b/flake.nix index bc3806d..722f077 100644 --- a/flake.nix +++ b/flake.nix @@ -28,6 +28,7 @@ with (import nixpkgs { system = "x86_64-linux"; }); { binaryninja = callPackage ./pkgs/binary-ninja-personal { }; + packettracer = callPackage ./pkgs/packettracer { }; }; apps."x86_64-linux" = diff --git a/pkgs/packettracer/default.nix b/pkgs/packettracer/default.nix new file mode 100644 index 0000000..79fbf87 --- /dev/null +++ b/pkgs/packettracer/default.nix @@ -0,0 +1,110 @@ +{ stdenv +, alsaLib +, autoPatchelfHook +, buildFHSUserEnv +, dbus +, dpkg +, expat +, fetchurl +, fontconfig +, glib +, libdrm +, libglvnd +, libpulseaudio +, libudev0-shim +, libxkbcommon +, libxml2 +, libxslt +, makeDesktopItem +, makeWrapper +, nspr +, nss +, xlibs +}: + +let + version = "8.0.0"; + + srcName = + if stdenv.hostPlatform.system == "x86_64-linux" then + "PacketTracer_800_amd64_build212_final.deb" + else throw "Unsupported system: ${stdenv.hostPlatform.system}"; + + ptFiles = stdenv.mkDerivation { + name = "PacketTracer"; + inherit version; + + src = fetchurl { + # This file was uploaded to archive.org by someone else, but I have verified the hash. + url = "https://archive.org/download/packet-tracer-800-build-212-mac-notarized/${srcName}"; + sha256 = "c9a78f9d1ee63fa421d3c531e9e1c209e425ba84d78c8e606594e4e59df535c9"; + }; + + nativeBuildInputs = [ + alsaLib + autoPatchelfHook + dbus + dpkg + expat + fontconfig + glib + libdrm + libglvnd + libpulseaudio + libudev0-shim + libxkbcommon + libxml2 + libxslt + makeWrapper + nspr + nss + xlibs.libICE + xlibs.libSM + xlibs.libX11 + xlibs.libxcb + xlibs.libXcomposite + xlibs.libXcursor + xlibs.libXdamage + xlibs.libXext + xlibs.libXfixes + xlibs.libXi + xlibs.libXrandr + xlibs.libXrender + xlibs.libXScrnSaver + xlibs.xcbutilimage + xlibs.xcbutilkeysyms + xlibs.xcbutilrenderutil + xlibs.xcbutilwm + ]; + + dontUnpack = true; + installPhase = '' + dpkg-deb -x $src $out + chmod 755 "$out" + makeWrapper "$out/opt/pt/bin/PacketTracer" "$out/bin/packettracer" \ + --prefix LD_LIBRARY_PATH : "$out/opt/pt/bin" + + # Keep source archive cached, to avoid re-downloading + ln -s "$src" "$out/usr/share/" + ''; + }; + + desktopItem = makeDesktopItem { + name = "cisco-pt.desktop"; + desktopName = "Packet Tracer"; + icon = "${ptFiles}/opt/pt/art/app.png"; + exec = "packettracer %f"; + mimeType = "application/x-pkt;application/x-pka;application/x-pkz;"; + }; + +in +buildFHSUserEnv { + name = "packettracer"; + runScript = "${ptFiles}/bin/packettracer"; + targetPkgs = pkgs: [ libudev0-shim ]; + + extraInstallCommands = '' + mkdir -p "$out/share/applications" + cp "${desktopItem}"/share/applications/* "$out/share/applications/" + ''; +}