proxmark3-rrg: support darwin + more build options

This commit is contained in:
Emily Trau 2023-06-13 21:45:36 +10:00
parent 450c30dd8d
commit f30598cd5b
3 changed files with 81 additions and 18 deletions

View file

@ -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

View file

@ -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;
};
}

View file

@ -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 { };