Skip to content

Commit

Permalink
bump lief to most recent main
Browse files Browse the repository at this point in the history
* bump lief to most recent main
  (3414ded8cdcbd9705f7871c66c212b15cd74ea69)
* created new nix directory and moved overlay there
* had to copy lief derivation from nixpkg for now since lief changed how
  it is built.
  • Loading branch information
fzakaria committed Sep 11, 2023
1 parent 96f0c82 commit c391445
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
let
pkgs = import nixpkgs {
inherit system;
overlays = [ poetry2nix.overlay (import ./overlay.nix) ];
overlays = [ poetry2nix.overlay (import ./nix/overlay.nix) ];
};
in
{
Expand Down
2 changes: 1 addition & 1 deletion derivation.nix → nix/derivation.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ poetry2nix, poetryOverrides }:
poetry2nix.mkPoetryApplication {
projectDir = ./.;
projectDir = ../.;
overrides = poetry2nix.overrides.withDefaults poetryOverrides;
}
44 changes: 44 additions & 0 deletions nix/lief.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This is an unreleased version of Lief that fixes a bug when generates GNU notes
# https://github.com/lief-project/LIEF/commit/3414ded8cdcbd9705f7871c66c212b15cd74ea69
# Nixpkgs derivation was updated to change how lief was built since it no longer has setup.py
# in the root of the directory.
# For now, we copy the derivation until it's merged into nixpkgs we are tracking.
# https://github.com/NixOS/nixpkgs/pull/251414
{ fetchFromGitHub, python, stdenv, cmake, ninja }:
let
pyEnv = python.withPackages (ps: [ ps.setuptools ps.tomli ps.pip ps.setuptools ]);
in
stdenv.mkDerivation rec {
pname = "lief";
version = "0.14.0-3414ded";
src = fetchFromGitHub {
owner = "lief-project";
repo = "LIEF";
rev = "3414ded8cdcbd9705f7871c66c212b15cd74ea69";
sha256 = "sha256-GJTj4w8HhAiC2bQAjEIqPw9feaOHL4fmAfLACioW0Q0=";
};
outputs = [ "out" "py" ];

nativeBuildInputs = [
cmake
ninja
];

# Not a propagatedBuildInput because only the $py output needs it; $out is
# just the library itself (e.g. C/C++ headers).
buildInputs = [
python
];

postBuild = ''
pushd /build/source/api/python
${pyEnv.interpreter} setup.py build --parallel=$NIX_BUILD_CORES
popd
'';

postInstall = ''
pushd /build/source/api/python
${pyEnv.interpreter} setup.py install --skip-build --root=/ --prefix=$py
popd
'';
}
8 changes: 7 additions & 1 deletion overlay.nix → nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ self: super: {
sqlelf = self.callPackage ./derivation.nix { };

sqlelf-env = self.poetry2nix.mkPoetryEnv {
projectDir = ./.;
projectDir = ../.;
overrides = self.poetry2nix.overrides.withDefaults self.poetryOverrides;
editablePackageSources = { sqlelf = ./sqlelf; };
};
Expand All @@ -16,10 +16,16 @@ self: super: {
};
});


lief-3414ded = self.callPackage ./lief.nix { python = self.python3; };

poetryOverrides = self: super: {
lief = super.toPythonModule super.pkgs.lief-3414ded.py;

sh = super.sh.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.poetry ];
});

apsw = super.apsw.overridePythonAttrs (old: rec {
version = "3.43.0.0";
src = super.pkgs.fetchFromGitHub {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "LICENSE"
[tool.poetry.dependencies]
python = ">=3.10,<4.0"
capstone = "^5.0.1"
lief = "^0.13.2"
lief = ">=0.13.2"
apsw = "^3.43.0.0"
# TODO(fzakaria): Would love to specify this as an exact version
# but I was getting weird failures with `nix build`
Expand Down

0 comments on commit c391445

Please sign in to comment.