From 450c30dd8d5b3b51db6c9194d01b7a608532a2f1 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Tue, 13 Jun 2023 21:21:14 +1000 Subject: [PATCH 1/2] whereami: init at unstable-2022-02-18 --- .../libraries/whereami/default.nix | 42 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 44 insertions(+) create mode 100644 pkgs/development/libraries/whereami/default.nix diff --git a/pkgs/development/libraries/whereami/default.nix b/pkgs/development/libraries/whereami/default.nix new file mode 100644 index 000000000000..8bda2ef46dcf --- /dev/null +++ b/pkgs/development/libraries/whereami/default.nix @@ -0,0 +1,42 @@ +{ lib +, stdenv +, fetchFromGitHub +}: +let + libExt = stdenv.hostPlatform.extensions.sharedLibrary; +in +stdenv.mkDerivation rec { + pname = "whereami"; + version = "unstable-2022-02-18"; + + src = fetchFromGitHub { + owner = "gpakosz"; + repo = pname; + rev = "ba364cd54fd431c76c045393b6522b4bff547f50"; + sha256 = "XhRqW0wdXzlmyBf1cjqtQvztuyV4buxVl19Q0uyEOhk="; + }; + + makeFlags = [ + "-C_gnu-make" + "build-library" + "binsubdir=platform" + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib $out/include + cp bin/platform/library${libExt} $out/lib/libwhereami${libExt} + cp src/whereami.h $out/include/whereami.h + + runHook postInstall + ''; + + meta = with lib; { + description = "Locate the current executable and running module/library"; + homepage = "https://github.com/gpakosz/whereami"; + license = with licenses; [ mit wtfpl ]; + maintainers = with maintainers; [ emilytrau ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e78a7e4b30fc..bffe1fe89dec 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -24710,6 +24710,8 @@ with pkgs; # bump when majoring of packages have updated webrtc-audio-processing = webrtc-audio-processing_0_3; + whereami = callPackage ../development/libraries/whereami { }; + wildmidi = callPackage ../development/libraries/wildmidi { }; wiredtiger = callPackage ../development/libraries/wiredtiger { }; From f30598cd5be47567a40e288742581e7651bf5d52 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Tue, 13 Jun 2023 21:45:36 +1000 Subject: [PATCH 2/2] proxmark3-rrg: support darwin + more build options --- .../proxmark3/darwin-always-gui.patch | 13 +++ .../security/proxmark3/proxmark3-rrg.nix | 82 +++++++++++++++---- pkgs/top-level/all-packages.nix | 4 +- 3 files changed, 81 insertions(+), 18 deletions(-) create mode 100644 pkgs/tools/security/proxmark3/darwin-always-gui.patch diff --git a/pkgs/tools/security/proxmark3/darwin-always-gui.patch b/pkgs/tools/security/proxmark3/darwin-always-gui.patch new file mode 100644 index 000000000000..99c4495e9661 --- /dev/null +++ b/pkgs/tools/security/proxmark3/darwin-always-gui.patch @@ -0,0 +1,13 @@ +diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c +index 6c77bfad3..0d41a2d6b 100644 +--- a/client/src/proxmark3.c ++++ b/client/src/proxmark3.c +@@ -1098,7 +1098,7 @@ int main(int argc, char *argv[]) { + + #ifdef HAVE_GUI + +-# if defined(_WIN32) ++# if defined(_WIN32) || (defined(__MACH__) && defined(__APPLE__)) + InitGraphics(argc, argv, script_cmds_file, script_cmd, stayInCommandLoop); + MainGraphics(); + # else diff --git a/pkgs/tools/security/proxmark3/proxmark3-rrg.nix b/pkgs/tools/security/proxmark3/proxmark3-rrg.nix index 6b021e970277..59b2ee8f253a 100644 --- a/pkgs/tools/security/proxmark3/proxmark3-rrg.nix +++ b/pkgs/tools/security/proxmark3/proxmark3-rrg.nix @@ -1,11 +1,28 @@ -{ lib, mkDerivation, fetchFromGitHub, pkg-config, gcc-arm-embedded, bluez5 +{ lib +, stdenv +, fetchFromGitHub +, pkg-config +, gcc-arm-embedded , readline - -, hardwarePlatform ? "PM3RDV4" - -, hardwarePlatformExtras ? "" }: - -mkDerivation rec { +, bzip2 +, openssl +, jansson +, whereami +, lua +, Foundation +, AppKit +, withGui ? true, wrapQtAppsHook, qtbase +, withPython ? true, python3 +, withBlueshark ? false, bluez5 +, withGeneric ? false +, withSmall ? false +, withoutFunctions ? [] +, hardwarePlatform ? if withGeneric then "PM3GENERIC" else "PM3RDV4" +, hardwarePlatformExtras ? lib.optionalString withBlueshark "BTADDON" +, standalone ? "LF_SAMYRUN" +}: +assert withBlueshark -> stdenv.hostPlatform.isLinux; +stdenv.mkDerivation rec { pname = "proxmark3-rrg"; version = "4.16191"; @@ -16,23 +33,54 @@ mkDerivation rec { sha256 = "sha256-l0aDp0s9ekUUHqkzGfVoSIf/4/GN2uiVGL/+QtKRCOs="; }; - nativeBuildInputs = [ pkg-config gcc-arm-embedded ]; - buildInputs = [ bluez5 readline ]; - - makeFlags = [ - "PLATFORM=${hardwarePlatform}" - "PLATFORM_EXTRAS=${hardwarePlatformExtras}" + patches = [ + # Don't check for DISPLAY env variable on Darwin. pm3 uses this to test if + # XQuartz is installed, however it is not actually required for GUI features + ./darwin-always-gui.patch ]; - installPhase = '' - install -Dt $out/bin client/proxmark3 - install -Dt $out/firmware bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf + postPatch = '' + # Remove hardcoded paths on Darwin + substituteInPlace Makefile.defs \ + --replace "/usr/bin/ar" "ar" \ + --replace "/usr/bin/ranlib" "ranlib" + # Replace hardcoded path to libwhereami + substituteInPlace client/Makefile \ + --replace "/usr/include/whereami.h" "${whereami}/include/whereami.h" ''; + nativeBuildInputs = [ + pkg-config + gcc-arm-embedded + ] ++ lib.optional withGui wrapQtAppsHook; + buildInputs = [ + readline + bzip2 + openssl + jansson + whereami + lua + ] ++ lib.optional withGui qtbase + ++ lib.optional withPython python3 + ++ lib.optional withBlueshark bluez5 + ++ lib.optionals stdenv.hostPlatform.isDarwin [ Foundation AppKit ]; + + makeFlags = [ + "PREFIX=${placeholder "out"}" + "UDEV_PREFIX=${placeholder "out"}/etc/udev/rules.d" + "PLATFORM=${hardwarePlatform}" + "PLATFORM_EXTRAS=${hardwarePlatformExtras}" + "STANDALONE=${standalone}" + "USE_BREW=0" + ] ++ lib.optional withSmall "PLATFORM_SIZE=256" + ++ map (x: "SKIP_${x}=1") withoutFunctions; + enableParallelBuilding = true; + meta = with lib; { description = "Client for proxmark3, powerful general purpose RFID tool"; homepage = "https://rfidresearchgroup.com/"; license = licenses.gpl2Plus; - maintainers = with maintainers; [ nyanotech ]; + maintainers = with maintainers; [ nyanotech emilytrau ]; + platforms = platforms.unix; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bffe1fe89dec..66f7828de9ec 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11555,7 +11555,9 @@ with pkgs; inherit (callPackages ../tools/security/proxmark3 { gcc-arm-embedded = gcc-arm-embedded-8; }) proxmark3 proxmark3-unstable; - proxmark3-rrg = libsForQt5.callPackage ../tools/security/proxmark3/proxmark3-rrg.nix { }; + proxmark3-rrg = libsForQt5.callPackage ../tools/security/proxmark3/proxmark3-rrg.nix { + inherit (darwin.apple_sdk.frameworks) Foundation AppKit; + }; proxychains = callPackage ../tools/networking/proxychains { };