You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pwndbg/nix/devshell.nix

93 lines
2.4 KiB
Nix

# Packages installed by this file should be kept in sync with setup-dev.sh and lint.sh requirements
{
pkgs ? # If pkgs is not defined, instantiate nixpkgs from locked commit
let
lock = (builtins.fromJSON (builtins.readFile ./flake.lock)).nodes.nixpkgs.locked;
nixpkgs = fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${lock.rev}.tar.gz";
sha256 = lock.narHash;
};
in
import nixpkgs { overlays = [ ]; },
python3 ? pkgs.python3,
inputs ? null,
...
}:
let
lib = pkgs.lib;
pyEnv = import ./pyenv.nix {
inherit
pkgs
lib
python3
inputs
;
isDev = true;
isEditable = true;
groups = [
"lldb"
"gdb"
];
};
jemalloc-static = pkgs.jemalloc.overrideAttrs (
finalAttrs: previousAttrs: {
version = "5.3.0"; # version match setup-dev.sh
src = pkgs.fetchurl {
url = "https://github.com/jemalloc/jemalloc/releases/download/${finalAttrs.version}/${finalAttrs.pname}-${finalAttrs.version}.tar.bz2";
sha256 = "sha256-LbgtHnEZ3z5xt2QCGbbf6EeJvAU3mDw7esT3GJrs/qo=";
};
configureFlags = (previousAttrs.configureFlags or [ ]) ++ [
"--enable-static"
"--disable-shared"
];
# debug symbols currently required for jemalloc.py type resolution
preBuild = ''
makeFlagsArray+=(CFLAGS="-O0 -g")
'';
postInstall = ''
${previousAttrs.postInstall or ""}
cp -v lib/libjemalloc.a $out/lib/
'';
dontStrip = true; # don't strip the debug symbols we added
}
);
in
{
default = pkgs.mkShell {
NIX_CONFIG = "extra-experimental-features = nix-command flakes";
# Anything not handled by the poetry env
nativeBuildInputs =
builtins.attrValues {
inherit (pkgs)
# from setup-dev.sh
nasm
gcc
curl
parallel
qemu
go
# for onegadget command
one_gadget
# from qemu-tests.sh
binutils
;
}
++ [
jemalloc-static
pyEnv
];
shellHook = ''
# lldb looks for the `debugserver` binary in `DEVELOPER_DIR`,
# but nixpkgs does not provide `debugserver` there
unset DEVELOPER_DIR
export PWNDBG_NO_AUTOUPDATE=1
export PWNDBG_NO_UV=1
export PWNDBG_VENV_PATH="${pyEnv}"
export REPO_ROOT=$(git rev-parse --show-toplevel)
'';
};
}