diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-04-28 14:39:00 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-06-10 08:52:36 +0000 |
commit | 693e64ef7421374338ddb1dc12b9573feec75972 (patch) | |
tree | 2526ac075d248699c35d63e04499890ee4381f5f /nixpkgs/pkgs/development/libraries/lief/default.nix | |
parent | 7014df2256694d97093d6f2bb1db340d346dea88 (diff) | |
parent | 8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17 (diff) | |
download | nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.gz nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.bz2 nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.lz nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.xz nixlib-693e64ef7421374338ddb1dc12b9573feec75972.tar.zst nixlib-693e64ef7421374338ddb1dc12b9573feec75972.zip |
Merge commit '8e4fe32876ca15e3d5eb3ecd3ca0b224417f5f17'
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/lief/default.nix')
-rw-r--r-- | nixpkgs/pkgs/development/libraries/lief/default.nix | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/nixpkgs/pkgs/development/libraries/lief/default.nix b/nixpkgs/pkgs/development/libraries/lief/default.nix index 953eee3b8bdb..872327ed4b8f 100644 --- a/nixpkgs/pkgs/development/libraries/lief/default.nix +++ b/nixpkgs/pkgs/development/libraries/lief/default.nix @@ -1,8 +1,64 @@ -{ lib, 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.4"; + + src = fetchFromGitHub { + owner = "lief-project"; + repo = "LIEF"; + rev = version; + sha256 = "DgsTrJ2+zdXJK6CdDOan7roakaaxQiwrVeiQnzJnk0A="; + }; + + 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"; |