2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchurl
|
2020-12-31 07:48:55 +00:00
|
|
|
, cmake, pkg-config, dbus, makeWrapper
|
2018-11-03 18:33:58 +00:00
|
|
|
, boost
|
2021-01-03 21:53:22 +00:00
|
|
|
, elfutils # for libdw
|
|
|
|
, git
|
|
|
|
, glib
|
|
|
|
, glm
|
|
|
|
, gtest
|
|
|
|
, libbfd
|
2018-11-03 18:33:58 +00:00
|
|
|
, libcap
|
2021-01-03 21:53:22 +00:00
|
|
|
, libdwarf
|
2018-11-03 18:33:58 +00:00
|
|
|
, libGL
|
|
|
|
, libglvnd
|
2021-01-03 21:53:22 +00:00
|
|
|
, lxc
|
|
|
|
, mesa
|
2018-11-03 18:33:58 +00:00
|
|
|
, properties-cpp
|
|
|
|
, protobuf
|
|
|
|
, protobufc
|
2021-01-03 21:53:22 +00:00
|
|
|
, python3
|
|
|
|
, runtimeShell
|
|
|
|
, SDL2
|
|
|
|
, SDL2_image
|
|
|
|
, systemd
|
2019-03-22 19:22:40 +00:00
|
|
|
, writeText
|
|
|
|
, writeScript
|
2018-11-03 18:33:58 +00:00
|
|
|
}:
|
|
|
|
|
2019-03-22 19:22:40 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
dbus-service = writeText "org.anbox.service" ''
|
|
|
|
[D-BUS Service]
|
|
|
|
Name=org.anbox
|
|
|
|
Exec=@out@/libexec/anbox-session-manager
|
|
|
|
'';
|
|
|
|
|
|
|
|
anbox-application-manager = writeScript "anbox-application-manager" ''
|
|
|
|
#!${runtimeShell}
|
|
|
|
|
|
|
|
${systemd}/bin/busctl --user call \
|
|
|
|
org.freedesktop.DBus \
|
|
|
|
/org/freedesktop/DBus \
|
|
|
|
org.freedesktop.DBus \
|
|
|
|
StartServiceByName "su" org.anbox 0
|
|
|
|
|
|
|
|
@out@/bin/anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
|
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2018-11-03 18:33:58 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "anbox";
|
2021-01-03 21:53:22 +00:00
|
|
|
version = "unstable-2020-11-29";
|
2018-11-03 18:33:58 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2021-01-03 21:53:22 +00:00
|
|
|
rev = "6c10125a7f13908d2cbe56d2d9ab09872755f265";
|
|
|
|
sha256 = "00bqssh4zcs0jj6w07b91719xkrpdw75vpcplwrvlhwsvl55f901";
|
|
|
|
fetchSubmodules = true;
|
2018-11-03 18:33:58 +00:00
|
|
|
};
|
|
|
|
|
2019-03-22 19:22:40 +00:00
|
|
|
nativeBuildInputs = [
|
2020-12-31 07:48:55 +00:00
|
|
|
cmake
|
|
|
|
pkg-config
|
2019-03-22 19:22:40 +00:00
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
2018-11-03 18:33:58 +00:00
|
|
|
buildInputs = [
|
2021-01-03 21:53:22 +00:00
|
|
|
boost
|
|
|
|
dbus
|
|
|
|
elfutils # libdw
|
|
|
|
glib
|
|
|
|
glm
|
|
|
|
gtest
|
|
|
|
libbfd
|
|
|
|
libcap
|
|
|
|
libdwarf
|
2019-03-22 19:22:40 +00:00
|
|
|
libGL
|
2021-01-03 21:53:22 +00:00
|
|
|
lxc
|
|
|
|
mesa
|
|
|
|
properties-cpp
|
|
|
|
protobuf protobufc
|
|
|
|
python3
|
|
|
|
SDL2 SDL2_image
|
|
|
|
systemd
|
2018-11-03 18:33:58 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
patchShebangs scripts
|
|
|
|
|
|
|
|
cat >cmake/FindGMock.cmake <<'EOF'
|
|
|
|
add_library(gtest INTERFACE)
|
|
|
|
target_include_directories(gtest INTERFACE ${gtest.dev}/include)
|
|
|
|
target_link_libraries(gtest INTERFACE ${gtest}/lib/libgtest.so ''${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
add_dependencies(gtest GMock)
|
|
|
|
|
|
|
|
add_library(gtest_main INTERFACE)
|
|
|
|
target_include_directories(gtest_main INTERFACE ${gtest.dev}/include)
|
|
|
|
target_link_libraries(gtest_main INTERFACE ${gtest}/lib/libgtest_main.so gtest)
|
|
|
|
|
|
|
|
add_library(gmock INTERFACE)
|
|
|
|
target_include_directories(gmock INTERFACE ${gtest.dev}/include)
|
|
|
|
target_link_libraries(gmock INTERFACE ${gtest}/lib/libgmock.so gtest)
|
|
|
|
|
|
|
|
add_library(gmock_main INTERFACE)
|
|
|
|
target_include_directories(gmock_main INTERFACE ${gtest.dev}/include)
|
|
|
|
target_link_libraries(gmock_main INTERFACE ${gtest}/lib/libgmock_main.so gmock gtest_main)
|
|
|
|
|
|
|
|
set(GTEST_LIBRARIES gtest)
|
|
|
|
set(GTEST_MAIN_LIBRARIES gtest_main)
|
|
|
|
set(GMOCK_LIBRARIES gmock gmock_main)
|
|
|
|
set(GTEST_BOTH_LIBRARIES ''${GTEST_LIBRARIES} ''${GTEST_MAIN_LIBRARIES})
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
wrapProgram $out/bin/anbox \
|
2021-01-15 14:45:37 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [libGL libglvnd]} \
|
2018-11-03 18:33:58 +00:00
|
|
|
--prefix PATH : ${git}/bin
|
|
|
|
|
2019-03-22 19:22:40 +00:00
|
|
|
mkdir -p $out/share/dbus-1/services
|
|
|
|
substitute ${dbus-service} $out/share/dbus-1/services/org.anbox.service \
|
|
|
|
--subst-var out
|
2018-11-03 18:33:58 +00:00
|
|
|
|
|
|
|
mkdir $out/libexec
|
2019-03-22 19:22:40 +00:00
|
|
|
makeWrapper $out/bin/anbox $out/libexec/anbox-session-manager \
|
|
|
|
--add-flags session-manager
|
2018-11-03 18:33:58 +00:00
|
|
|
|
2019-03-22 19:22:40 +00:00
|
|
|
substitute ${anbox-application-manager} $out/bin/anbox-application-manager \
|
|
|
|
--subst-var out
|
2018-11-03 18:33:58 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.image = let
|
|
|
|
imgroot = "https://build.anbox.io/android-images";
|
2019-03-22 22:27:26 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
armv7l-linux = fetchurl {
|
2018-11-03 18:33:58 +00:00
|
|
|
url = imgroot + "/2017/06/12/android_1_armhf.img";
|
|
|
|
sha256 = "1za4q6vnj8wgphcqpvyq1r8jg6khz7v6b7h6ws1qkd5ljangf1w5";
|
|
|
|
};
|
2019-03-22 22:27:26 +00:00
|
|
|
aarch64-linux = fetchurl {
|
2018-11-03 18:33:58 +00:00
|
|
|
url = imgroot + "/2017/08/04/android_1_arm64.img";
|
|
|
|
sha256 = "02yvgpx7n0w0ya64y5c7bdxilaiqj9z3s682l5s54vzfnm5a2bg5";
|
|
|
|
};
|
2019-03-22 22:27:26 +00:00
|
|
|
x86_64-linux = fetchurl {
|
2018-11-03 18:33:58 +00:00
|
|
|
url = imgroot + "/2018/07/19/android_amd64.img";
|
|
|
|
sha256 = "1jlcda4q20w30cm9ikm6bjq01p547nigik1dz7m4v0aps4rws13b";
|
|
|
|
};
|
2019-03-22 22:27:26 +00:00
|
|
|
}.${stdenv.system} or null;
|
2018-11-03 18:33:58 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://anbox.io";
|
2019-03-22 19:22:40 +00:00
|
|
|
description = "Android in a box";
|
2018-11-03 18:33:58 +00:00
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = with maintainers; [ edwtjo ];
|
2019-03-23 19:57:07 +00:00
|
|
|
platforms = [ "armv7l-linux" "aarch64-linux" "x86_64-linux" ];
|
2018-11-03 18:33:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|