Skip to content

Commit

Permalink
proxmark3-rrg: support darwin + more build options
Browse files Browse the repository at this point in the history
  • Loading branch information
emilytrau committed Jun 16, 2023
1 parent 450c30d commit f30598c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 17 deletions.
13 changes: 13 additions & 0 deletions pkgs/tools/security/proxmark3/darwin-always-gui.patch
Original file line number Diff line number Diff line change
@@ -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
80 changes: 64 additions & 16 deletions pkgs/tools/security/proxmark3/proxmark3-rrg.nix
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -16,23 +33,54 @@ mkDerivation rec {
sha256 = "sha256-l0aDp0s9ekUUHqkzGfVoSIf/4/GN2uiVGL/+QtKRCOs=";
};

nativeBuildInputs = [ pkg-config gcc-arm-embedded ];
buildInputs = [ bluez5 readline ];
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
];

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}"
];

installPhase = ''
install -Dt $out/bin client/proxmark3
install -Dt $out/firmware bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf
'';
"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;
};
}
4 changes: 3 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };

Expand Down

0 comments on commit f30598c

Please sign in to comment.