nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 llvmPackages,
4 fetchFromGitHub,
5 opencflite,
6 libuuid,
7 zlib,
8}:
9
10let
11 stdenv = llvmPackages.libcxxStdenv;
12in
13stdenv.mkDerivation {
14 pname = "maloader";
15 version = "0-unstable-2018-05-02";
16
17 src = fetchFromGitHub {
18 owner = "shinh";
19 repo = "maloader";
20 rev = "464a90fdfd06a54c9da5d1a3725ed6229c0d3d60";
21 hash = "sha256-0N3+tr8XUsn3WhJNsPVknumBrfMgDawTEXVRkIs/IV8=";
22 };
23
24 postPatch = ''
25 substituteInPlace ld-mac.cc \
26 --replace-fail 'loadLibMac(mypath)' 'loadLibMac("${placeholder "out"}/lib/")' \
27 --replace-fail 'libCoreFoundation.so' '${opencflite}/lib/libCoreFoundation.so'
28 substituteInPlace libmac/stack_protector-obsd.c \
29 --replace-fail 'sys/sysctl.h' 'linux/sysctl.h'
30 '';
31
32 buildInputs = [
33 libuuid
34 zlib
35 ];
36
37 buildFlags = [
38 "USE_LIBCXX=1"
39 "release"
40 ];
41
42 env.NIX_CFLAGS_COMPILE = "-Wno-error=unused-command-line-argument";
43
44 installPhase = ''
45 runHook preInstall
46
47 install -vD libmac.so "$out/lib/libmac.so"
48
49 for bin in extract macho2elf ld-mac; do
50 install -vD "$bin" "$out/bin/$bin"
51 done
52
53 runHook postInstall
54 '';
55
56 meta = {
57 description = "Mach-O loader for Linux";
58 homepage = "https://github.com/shinh/maloader";
59 license = lib.licenses.bsd2;
60 maintainers = with lib.maintainers; [ wegank ];
61 inherit (opencflite.meta) platforms;
62 };
63}