summary refs log tree commit diff
path: root/pkgs/development/libraries/lief
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
commit62614cbef7da005c1eda8c9400160f6bcd6546b8 (patch)
treec2630f69080637987b68acb1ee8676d2681fe304 /pkgs/development/libraries/lief
parentd9c82ed3044c72cecf01c6ea042489d30914577c (diff)
parente24069138dfec3ef94f211f1da005bb5395adc11 (diff)
downloadnixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.gz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.bz2
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.lz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.xz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.zst
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.zip
Merge branch 'nixpkgs-update' into master
Diffstat (limited to 'pkgs/development/libraries/lief')
-rw-r--r--pkgs/development/libraries/lief/default.nix66
1 files changed, 61 insertions, 5 deletions
diff --git a/pkgs/development/libraries/lief/default.nix b/pkgs/development/libraries/lief/default.nix
index 0854987436e..70640806190 100644
--- a/pkgs/development/libraries/lief/default.nix
+++ b/pkgs/development/libraries/lief/default.nix
@@ -1,10 +1,66 @@
-{ stdenv, fetchzip }:
+{ lib
+, stdenv
+, fetchFromGitHub
+, python
+, cmake
+}:
 
-fetchzip {
-  url = "https://github.com/lief-project/LIEF/releases/download/0.9.0/LIEF-0.9.0-Linux.tar.gz";
-  sha256 = "1c47hwd00bp4mqd4p5b6xjfl89c3wwk9ccyc3a2gk658250g2la6";
+let
+  pyEnv = python.withPackages (ps: [ ps.setuptools ]);
+in
+stdenv.mkDerivation rec {
+  pname = "lief";
+  version = "0.11.5";
 
-  meta = with stdenv.lib; {
+  src = fetchFromGitHub {
+    owner = "lief-project";
+    repo = "LIEF";
+    rev = version;
+    sha256 = "sha256-crYFBeX+YaIvVAv3uvGEeNCg+ZbUryr0NacDG56TUGE=";
+  };
+
+  outputs = [ "out" "py" ];
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  # Not a propagatedBuildInput because only the $py output needs it; $out is
+  # just the library itself (e.g. C/C++ headers).
+  buildInputs = [
+    python
+  ];
+
+  dontUseCmakeConfigure = true;
+
+  buildPhase = ''
+    runHook preBuild
+
+    substituteInPlace setup.py \
+      --replace 'cmake_args = []' "cmake_args = [ \"-DCMAKE_INSTALL_PREFIX=$prefix\" ]"
+    ${pyEnv.interpreter} setup.py --sdk build --parallel=$NIX_BUILD_CORES
+
+    runHook postBuild
+  '';
+
+  # I was unable to find a way to build the library itself and have it install
+  # to $out, while also installing the Python bindings to $py without building
+  # the project twice (using cmake), so this is the best we've got. It uses
+  # something called CPack to create the tarball, but it's not obvious to me
+  # *how* that happens, or how to intercept it to just get the structured
+  # library output.
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out $py/nix-support
+    echo "${python}" >> $py/nix-support/propagated-build-inputs
+    tar xf build/*.tar.gz --directory $out --strip-components 1
+    ${pyEnv.interpreter} setup.py install --skip-build --root=/ --prefix=$py
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
     description = "Library to Instrument Executable Formats";
     homepage = "https://lief.quarkslab.com/";
     license = [ licenses.asl20 ];