about summary refs log tree commit diff
path: root/pkgs/by-name/pw/pwndbg/package.nix
blob: 2967130b7fd1048494d34f8ad66edd61ba4c9830 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ lib
, stdenv
, python3
, fetchFromGitHub
, makeWrapper
, gdb
}:

let
  pwndbg-py = python3.pkgs.pwndbg;

  pythonPath = python3.pkgs.makePythonPath [ pwndbg-py ];

  binPath = lib.makeBinPath ([
    python3.pkgs.pwntools # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/wrappers/checksec.py#L8
  ] ++ lib.optionals stdenv.isLinux [
    python3.pkgs.ropper # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/commands/ropper.py#L30
    python3.pkgs.ropgadget # ref: https://github.com/pwndbg/pwndbg/blob/2022.12.19/pwndbg/commands/rop.py#L32
  ]);
in
stdenv.mkDerivation rec {
  pname = "pwndbg";
  version = lib.getVersion pwndbg-py;
  format = "other";

  inherit (pwndbg-py) src;

  nativeBuildInputs = [ makeWrapper ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/pwndbg
    cp gdbinit.py $out/share/pwndbg
    chmod +x $out/share/pwndbg/gdbinit.py

    # Don't require an in-package venv
    touch $out/share/pwndbg/.skip-venv

    makeWrapper ${gdb}/bin/gdb $out/bin/pwndbg \
      --add-flags "-q -x $out/share/pwndbg/gdbinit.py" \
      --prefix PATH : ${binPath} \
      --set PYTHONPATH ${pythonPath} \

    runHook postInstall
  '';

  meta = with lib; {
    description = "Exploit Development and Reverse Engineering with GDB Made Easy";
    mainProgram = "pwndbg";
    homepage = "https://github.com/pwndbg/pwndbg";
    license = licenses.mit;
    platforms = platforms.all;
    maintainers = with maintainers; [ mic92 patryk4815 msanft ];
    # not supported on aarch64-darwin see: https://inbox.sourceware.org/gdb/3185c3b8-8a91-4beb-a5d5-9db6afb93713@Spark/
    broken = stdenv.isDarwin && stdenv.isAarch64;
  };
}