mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
46 lines
1.5 KiB
Nix
46 lines
1.5 KiB
Nix
# Copyright (c) 2019-2023, see AUTHORS. Licensed under MIT License, see LICENSE.
|
|
|
|
{ stdenv
|
|
, fetchFromGitHub
|
|
, talloc
|
|
, static ? true
|
|
, outputBinaryName ? "proot-static"
|
|
}:
|
|
|
|
stdenv.mkDerivation {
|
|
pname = "proot-termux";
|
|
version = "unstable-2023-05-13";
|
|
|
|
src = fetchFromGitHub {
|
|
repo = "proot";
|
|
owner = "termux";
|
|
rev = "2d7c70eec7e2688e465c7bfba60c927fad0abfb1";
|
|
sha256 = "sha256-FgK5Rvl95yfH+aqTsJZ8HzSsCYIE3iLiQMFIlw0Z6oc=";
|
|
};
|
|
|
|
# ashmem.h is rather small, our needs are even smaller, so just define these:
|
|
preConfigure = ''
|
|
mkdir -p fake-ashmem/linux; cat > fake-ashmem/linux/ashmem.h << EOF
|
|
#include <linux/limits.h>
|
|
#include <linux/ioctl.h>
|
|
#include <string.h>
|
|
#define __ASHMEMIOC 0x77
|
|
#define ASHMEM_NAME_LEN 256
|
|
#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN])
|
|
#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t)
|
|
#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4)
|
|
EOF
|
|
substituteInPlace src/arch.h --replace \
|
|
'#define HAS_LOADER_32BIT true' \
|
|
""
|
|
! (grep -F '#define HAS_LOADER_32BIT' src/arch.h)
|
|
'';
|
|
buildInputs = [ talloc ];
|
|
patches = [ ./detranslate-empty.patch ];
|
|
makeFlags = [ "-Csrc" "V=1" ];
|
|
CFLAGS = [ "-O3" "-I../fake-ashmem" ] ++
|
|
(if static then [ "-static" ] else [ ]);
|
|
LDFLAGS = if static then [ "-static" ] else [ ];
|
|
preInstall = "${stdenv.cc.targetPrefix}strip src/proot";
|
|
installPhase = "install -D -m 0755 src/proot $out/bin/${outputBinaryName}";
|
|
}
|