From 48d0b14941cc016eb1e8715e40ed9d50d9f9aa14 Mon Sep 17 00:00:00 2001 From: Quentin Kaiser Date: Mon, 16 Oct 2023 17:31:56 +0200 Subject: [PATCH] fixing lief nix --- nix/_sources/generated.json | 20 +++++++++++++++++++ nix/_sources/generated.nix | 11 +++++++++++ nvfetcher.toml | 4 ++++ overlay.nix | 38 ++++++++++++++++++++++++++++--------- 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/nix/_sources/generated.json b/nix/_sources/generated.json index b40a3d51d2..1c3e7b022c 100644 --- a/nix/_sources/generated.json +++ b/nix/_sources/generated.json @@ -14,6 +14,26 @@ }, "version": "0.4.5" }, + "lief": { + "cargoLocks": null, + "date": null, + "extract": null, + "name": "lief", + "passthru": null, + "pinned": false, + "src": { + "deepClone": false, + "fetchSubmodules": false, + "leaveDotGit": false, + "name": null, + "owner": "lief-project", + "repo": "LIEF", + "rev": "0.13.2", + "sha256": "sha256-lH4SqwPB2Jp/wUI2Cll67PQbHbwMqpNuLy/ei8roiHg=", + "type": "github" + }, + "version": "0.13.2" + }, "lzallright": { "cargoLocks": { "Cargo.lock": [ diff --git a/nix/_sources/generated.nix b/nix/_sources/generated.nix index 2191a8280c..8d8619a003 100644 --- a/nix/_sources/generated.nix +++ b/nix/_sources/generated.nix @@ -9,6 +9,17 @@ sha256 = "sha256-+cPOzzO3bCQAu8LrbjUJ5S/SR5OFitOYLIu5L9t/q+k="; }; }; + lief = { + pname = "lief"; + version = "0.13.2"; + src = fetchFromGitHub { + owner = "lief-project"; + repo = "LIEF"; + rev = "0.13.2"; + fetchSubmodules = false; + sha256 = "sha256-lH4SqwPB2Jp/wUI2Cll67PQbHbwMqpNuLy/ei8roiHg="; + }; + }; lzallright = { pname = "lzallright"; version = "v0.2.3"; diff --git a/nvfetcher.toml b/nvfetcher.toml index 66d9c20a7b..998e279575 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml @@ -18,3 +18,7 @@ fetch.pypi = "treelib" [pyfatfs] src.pypi = "pyfatfs" fetch.pypi = "pyfatfs" + +[lief] +src.github_tag = "lief-project/LIEF" +fetch.github = "lief-project/LIEF" diff --git a/overlay.nix b/overlay.nix index 1b19017a5a..95faac9245 100644 --- a/overlay.nix +++ b/overlay.nix @@ -11,18 +11,38 @@ inputs: final: prev: hardeningDisable = (super.hardeningDisable or [ ]) ++ [ "fortify3" ]; }); - # Lief 12.3 incompatibility with Cmake 3.26 + # Own package updated independently of nixpkgs + jefferson = final.callPackage ./nix/jefferson { }; + lief = prev.lief.overrideAttrs (super: { - postPatch = '' - substituteInPlace setup.py \ - --replace \ - 'cmake_args = ["-DLIEF_FORCE_API_EXPORTS=ON", "-DLIEF_PYTHON_API=on"]' \ - 'cmake_args = ["-DLIEF_FORCE_API_EXPORTS=ON", "-DLIEF_PYTHON_API=on", "-DLIEF_EXAMPLES=off"]' + outputs = [ "out" "py" ]; + + nativeBuildInputs = [ + prev.cmake + prev.ninja + ]; + + # Not a propagatedBuildInput because only the $py output needs it; $out is + # just the library itself (e.g. C/C++ headers). + buildInputs = [ + final.python3 + final.python3.pkgs.setuptools + final.python3.pkgs.tomli + ]; + + postBuild = '' + pushd /build/source/api/python + ${final.python3.interpreter} setup.py build --parallel=$NIX_BUILD_CORES + popd ''; - }); - # Own package updated independently of nixpkgs - jefferson = final.callPackage ./nix/jefferson { }; + postInstall = '' + pushd /build/source/api/python + ${final.python3.interpreter} setup.py install --skip-build --root=/ --prefix=$py + popd + ''; + + }); python3 = prev.python3 // { pkgs = prev.python3.pkgs.overrideScope