2021-01-15 22:18:51 +00:00
|
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchurl
|
2023-10-09 19:29:22 +00:00
|
|
|
|
, callPackage
|
|
|
|
|
, fetchpatch
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, cmake, pkg-config, dbus, makeWrapper
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, boost
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, elfutils # for libdw
|
|
|
|
|
, git
|
|
|
|
|
, glib
|
|
|
|
|
, glm
|
|
|
|
|
, gtest
|
|
|
|
|
, libbfd
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, libcap
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, libdwarf
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, libGL
|
|
|
|
|
, libglvnd
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, lxc
|
|
|
|
|
, mesa
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, properties-cpp
|
|
|
|
|
, protobuf
|
|
|
|
|
, protobufc
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, python3
|
|
|
|
|
, runtimeShell
|
|
|
|
|
, SDL2
|
|
|
|
|
, SDL2_image
|
|
|
|
|
, systemd
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, writeText
|
2023-10-09 19:29:22 +00:00
|
|
|
|
, writeShellScript
|
|
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
dbus-service = writeText "org.anbox.service" ''
|
|
|
|
|
[D-BUS Service]
|
|
|
|
|
Name=org.anbox
|
|
|
|
|
Exec=@out@/libexec/anbox-session-manager
|
|
|
|
|
'';
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
anbox-application-manager = writeShellScript "anbox-application-manager" ''
|
|
|
|
|
exec @out@/bin/anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
pname = "anbox";
|
2023-10-09 19:29:22 +00:00
|
|
|
|
version = "unstable-2023-02-03";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
|
owner = pname;
|
|
|
|
|
repo = pname;
|
2023-10-09 19:29:22 +00:00
|
|
|
|
rev = "ddf4c57ebbe3a2e46099087570898ab5c1e1f279";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
sha256 = "sha256-QXWhatewiUDQ93cH1UZsYgbjUxpgB1ajtGFYZnKmabc=";
|
2021-01-09 10:05:03 +00:00
|
|
|
|
fetchSubmodules = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2021-01-15 22:18:51 +00:00
|
|
|
|
cmake
|
|
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
|
makeWrapper
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
buildInputs = [
|
2021-01-09 10:05:03 +00:00
|
|
|
|
boost
|
|
|
|
|
dbus
|
|
|
|
|
elfutils # libdw
|
|
|
|
|
glib
|
|
|
|
|
glm
|
|
|
|
|
gtest
|
|
|
|
|
libbfd
|
|
|
|
|
libcap
|
|
|
|
|
libdwarf
|
2020-04-24 23:36:52 +00:00
|
|
|
|
libGL
|
2021-01-09 10:05:03 +00:00
|
|
|
|
lxc
|
|
|
|
|
mesa
|
|
|
|
|
properties-cpp
|
|
|
|
|
protobuf protobufc
|
|
|
|
|
python3
|
|
|
|
|
SDL2 SDL2_image
|
|
|
|
|
systemd
|
2020-04-24 23:36:52 +00:00
|
|
|
|
];
|
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
|
# Flag needed by GCC 12 but unrecognized by GCC 9 (aarch64-linux default now)
|
2023-03-04 12:14:45 +00:00
|
|
|
|
env.NIX_CFLAGS_COMPILE = toString (lib.optionals (with stdenv; cc.isGNU && lib.versionAtLeast cc.version "12") [
|
2023-02-16 17:41:37 +00:00
|
|
|
|
"-Wno-error=mismatched-new-delete"
|
2023-03-04 12:14:45 +00:00
|
|
|
|
]);
|
2023-02-16 17:41:37 +00:00
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
prePatch = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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
|
|
|
|
|
'';
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
patches = [
|
|
|
|
|
# Fixes compatibility with lxc 4
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://git.alpinelinux.org/aports/plain/community/anbox/lxc4.patch?id=64243590a16aee8d4e72061886fc1b15256492c3";
|
|
|
|
|
sha256 = "1da5xyzyjza1g2q9nbxb4p3njj2sf3q71vkpvmmdphia5qnb0gk5";
|
|
|
|
|
})
|
|
|
|
|
# Wait 10× more time when starting
|
|
|
|
|
# Not *strictly* needed, but helps a lot on slower hardware
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://git.alpinelinux.org/aports/plain/community/anbox/give-more-time-to-start.patch?id=058b56d4b332ef3379551b343bf31e0f2004321a";
|
|
|
|
|
sha256 = "0iiz3c7fgfgl0dvx8sf5hv7a961xqnihwpz6j8r0ib9v8piwxh9a";
|
|
|
|
|
})
|
|
|
|
|
# Ensures generated desktop files work on store path change
|
|
|
|
|
./0001-NixOS-Use-anbox-from-PATH-in-desktop-files.patch
|
|
|
|
|
# Provide window icons
|
|
|
|
|
(fetchpatch {
|
|
|
|
|
url = "https://github.com/samueldr/anbox/commit/2387f4fcffc0e19e52e58fb6f8264fbe87aafe4d.patch";
|
|
|
|
|
sha256 = "12lmr0kxw1n68g3abh1ak5awmpczfh75c26f53jc8qpvdvv1ywha";
|
|
|
|
|
})
|
|
|
|
|
];
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
postInstall = ''
|
|
|
|
|
wrapProgram $out/bin/anbox \
|
2023-10-09 19:29:22 +00:00
|
|
|
|
--set SDL_VIDEO_X11_WMCLASS "anbox" \
|
2021-02-05 17:12:51 +00:00
|
|
|
|
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [libGL libglvnd]} \
|
2020-04-24 23:36:52 +00:00
|
|
|
|
--prefix PATH : ${git}/bin
|
|
|
|
|
|
|
|
|
|
mkdir -p $out/share/dbus-1/services
|
|
|
|
|
substitute ${dbus-service} $out/share/dbus-1/services/org.anbox.service \
|
|
|
|
|
--subst-var out
|
|
|
|
|
|
|
|
|
|
mkdir $out/libexec
|
|
|
|
|
makeWrapper $out/bin/anbox $out/libexec/anbox-session-manager \
|
|
|
|
|
--add-flags session-manager
|
|
|
|
|
|
|
|
|
|
substitute ${anbox-application-manager} $out/bin/anbox-application-manager \
|
|
|
|
|
--subst-var out
|
2023-10-09 19:29:22 +00:00
|
|
|
|
chmod +x $out/bin/anbox-application-manager
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
passthru.tests = { inherit (nixosTests) anbox; };
|
|
|
|
|
passthru.image = callPackage ./postmarketos-image.nix { };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
homepage = "https://anbox.io";
|
|
|
|
|
description = "Android in a box";
|
|
|
|
|
license = licenses.gpl2;
|
|
|
|
|
maintainers = with maintainers; [ edwtjo ];
|
|
|
|
|
platforms = [ "armv7l-linux" "aarch64-linux" "x86_64-linux" ];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|