-
Notifications
You must be signed in to change notification settings - Fork 855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nix dev shell #2166
Merged
+140
−37
Merged
Nix dev shell #2166
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use_flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,8 +91,9 @@ gdb.txt | |
# venv | ||
.venv/ | ||
|
||
# Nix build stuff | ||
result-* | ||
# Nix build and dev shell | ||
result* | ||
.direnv/ | ||
|
||
# Vim | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# This 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 | ||
pyEnv = import ./pyenv.nix { | ||
inherit pkgs python3 inputs; | ||
lib = pkgs.lib; | ||
isDev = true; | ||
}; | ||
in | ||
{ | ||
default = pkgs.mkShell { | ||
NIX_CONFIG = "extra-experimental-features = nix-command flakes repl-flake"; | ||
# Anything not handled by the poetry env | ||
nativeBuildInputs = with pkgs; [ | ||
# from setup-dev.sh | ||
nasm | ||
gcc | ||
curl | ||
gdb | ||
parallel | ||
qemu | ||
netcat-openbsd | ||
zig_0_10 # matches setup-dev.sh | ||
go | ||
|
||
pyEnv | ||
]; | ||
shellHook = '' | ||
export PWNDBG_VENV_PATH="PWNDBG_PLEASE_SKIP_VENV" | ||
export ZIGPATH="${pkgs.lib.getBin pkgs.zig_0_10}/bin/" | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
pkgs ? import <nixpkgs> { }, | ||
python3 ? pkgs.python3, | ||
inputs ? null, | ||
isDev ? false, | ||
lib, | ||
... | ||
}: | ||
pkgs.poetry2nix.mkPoetryEnv { | ||
groups = lib.optionals isDev [ "dev" ]; | ||
checkGroups = lib.optionals isDev [ "dev" ]; | ||
projectDir = inputs.pwndbg; | ||
python = python3; | ||
overrides = pkgs.poetry2nix.overrides.withDefaults ( | ||
self: super: { | ||
pip = python3.pkgs.pip; # fix infinite loop in nix, look here: https://github.com/nix-community/poetry2nix/issues/1184#issuecomment-1644878841 | ||
unicorn = python3.pkgs.unicorn; # fix build for aarch64 (but it will use same version like in nixpkgs) | ||
|
||
# disable build from source, because rust's hash had to be repaired many times, see: PR https://github.com/pwndbg/pwndbg/pull/2024 | ||
cryptography = super.cryptography.override { preferWheel = true; }; | ||
|
||
unix-ar = super.unix-ar.overridePythonAttrs (old: { | ||
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ]; | ||
}); | ||
|
||
pt = super.pt.overridePythonAttrs (old: { | ||
buildInputs = (old.buildInputs or [ ]) ++ [ super.poetry-core ]; | ||
}); | ||
capstone = super.capstone.overridePythonAttrs (old: { | ||
# fix darwin | ||
preBuild = pkgs.lib.optionalString pkgs.stdenv.isDarwin '' | ||
sed -i 's/^IS_APPLE := .*$/IS_APPLE := 1/' ./src/Makefile | ||
''; | ||
# fix build for aarch64: https://github.com/capstone-engine/capstone/issues/2102 | ||
postPatch = pkgs.lib.optionalString pkgs.stdenv.isLinux '' | ||
substituteInPlace setup.py --replace manylinux1 manylinux2014 | ||
''; | ||
}); | ||
sortedcontainers-stubs = super.sortedcontainers-stubs.overridePythonAttrs (old: { | ||
buildInputs = (old.buildInputs or [ ]) ++ [ super.poetry-core ]; | ||
}); | ||
|
||
# Dev-only dependencies | ||
|
||
# Because compiling mypy is slow | ||
mypy = super.mypy.override { preferWheel = true; }; | ||
types-gdb = super.types-gdb.overridePythonAttrs (old: { | ||
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ]; | ||
}); | ||
vermin = super.vermin.overridePythonAttrs (old: { | ||
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ]; | ||
}); | ||
# Hash issues, so just wheel | ||
ruff = super.ruff.override { preferWheel = true; }; | ||
} | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sys.path.insert(0, '$out/share/pwndbg/')
🤔 why is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyEnv
only provides the dependencies of pwndbg, whereas forgdbinit.py
toimport pwndbg
, it needs to import fromshare/pwndbg/
as that is where thepwndbg
python module is installed to.This is without that line:
If there's some better way, happy to change it.
Reminds me even though
pwndbg.nix
links the.venv/
folder, there is no activation script created by the poetry derivation in.venv/bin/
. Is anyone actually using the venv on nix? Since it won't include pwndbg (as it only links the poetry sitePackages) I think it might not work? Maybe I'm missing something.