9 pwndbg-py = python3.pkgs.pwndbg;
11 pythonPath = python3.pkgs.makePythonPath [ pwndbg-py ];
13 binPath = lib.makeBinPath ([
14 python3.pkgs.pwntools # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/wrappers/checksec.py#L8
15 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
16 python3.pkgs.ropper # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/commands/ropper.py#L30
17 python3.pkgs.ropgadget # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/commands/rop.py#L32
22 version = lib.getVersion pwndbg-py;
25 inherit (pwndbg-py) src;
27 nativeBuildInputs = [ makeWrapper ];
32 mkdir -p $out/share/pwndbg
33 cp gdbinit.py $out/share/pwndbg/gdbinit.py
34 chmod +x $out/share/pwndbg/gdbinit.py
35 # First line is a import from future, so we need to append our imports after that
36 sed '2 i import sys, os
37 3 i [sys.path.append(p) for p in "${pythonPath}".split(":")]
38 4 i os.environ["PATH"] += ":${binPath}"' -i $out/share/pwndbg/gdbinit.py
40 # Don't require an in-package venv
41 touch $out/share/pwndbg/.skip-venv
43 makeWrapper ${gdb}/bin/gdb $out/bin/pwndbg \
44 --add-flags "-q -x $out/share/pwndbg/gdbinit.py"
49 doInstallCheck = true;
50 installCheckPhase = ''
51 runHook preInstallCheck
53 # Check if pwndbg is installed correctly
54 HOME=$TMPDIR LC_CTYPE=C.UTF-8 $out/bin/pwndbg -ex exit
56 runHook postInstallCheck
60 description = "Exploit Development and Reverse Engineering with GDB Made Easy";
61 mainProgram = "pwndbg";
62 homepage = "https://github.com/pwndbg/pwndbg";
63 license = licenses.mit;
64 platforms = platforms.all;
65 maintainers = with maintainers; [ mic92 patryk4815 msanft ];
66 # not supported on aarch64-darwin see: https://inbox.sourceware.org/gdb/3185c3b8-8a91-4beb-a5d5-9db6afb93713@Spark/
67 broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64;