From 0ad6321f79b4501d4dc0dd626b997faa0bed9509 Mon Sep 17 00:00:00 2001 From: Alexander Sosedkin Date: Sun, 3 Jul 2022 19:03:00 +0200 Subject: [PATCH] pkgs: use non-prebuilt SDK --- modules/environment/login/default.nix | 2 +- pkgs/cross-compiling/cross-pkgs.nix | 22 ++++++---------- pkgs/cross-compiling/proot-termux.nix | 8 +++--- pkgs/proot-termux/default.nix | 36 ++++++++++++++++----------- tests/proot-test.nix | 12 ++++----- 5 files changed, 38 insertions(+), 42 deletions(-) diff --git a/modules/environment/login/default.nix b/modules/environment/login/default.nix index aefab1a..cabaa12 100644 --- a/modules/environment/login/default.nix +++ b/modules/environment/login/default.nix @@ -82,7 +82,7 @@ in environment.files = { inherit login loginInner; - prootStatic = "/nix/store/scj2cqyvcra7dcan4y73n0459ac7fms7-proot-termux-aarch64-unknown-linux-android-unstable-2022-05-03"; + prootStatic = "/nix/store/wsgnxpmrdmjy7qrsxvp7r5jandbabzjl-proot-termux-static-aarch64-unknown-linux-android-unstable-2022-05-03"; }; }; diff --git a/pkgs/cross-compiling/cross-pkgs.nix b/pkgs/cross-compiling/cross-pkgs.nix index 2ae9b1e..814a0e6 100644 --- a/pkgs/cross-compiling/cross-pkgs.nix +++ b/pkgs/cross-compiling/cross-pkgs.nix @@ -1,25 +1,19 @@ -# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE. +# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. -{ config, path }: +{ config }: let loadNixpkgs = import ../lib/load-nixpkgs.nix; crossSystem = { config = "${config.build.arch}-unknown-linux-android"; - ndkVer = "21"; - - # that one is cool because it could make its way on-device one day, - # but it currently isn't static-friendly: - # sdkVer = "30"; - # libc = "bionic"; - # useAndroidPrebuilt = false; - # useLLVM = true; - - # use that one instead - sdkVer = "29"; - useAndroidPrebuilt = true; + sdkVer = "32"; + libc = "bionic"; + useAndroidPrebuilt = false; + useLLVM = true; + isStatic = true; }; + in loadNixpkgs { inherit crossSystem; } diff --git a/pkgs/cross-compiling/proot-termux.nix b/pkgs/cross-compiling/proot-termux.nix index 695f0de..2f2a05a 100644 --- a/pkgs/cross-compiling/proot-termux.nix +++ b/pkgs/cross-compiling/proot-termux.nix @@ -1,15 +1,13 @@ -# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE. +# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. { callPackage, tallocStatic }: let pkgsCross = callPackage ./cross-pkgs.nix { }; - - stdenv = pkgsCross.pkgsStatic.stdenvAdapters.makeStaticBinaries pkgsCross.stdenv; + stdenv = pkgsCross.stdenvAdapters.makeStaticBinaries pkgsCross.stdenv; in - callPackage ../proot-termux { - pkgs = pkgsCross; + pkgsCross.callPackage ../proot-termux { talloc = tallocStatic; inherit stdenv; } diff --git a/pkgs/proot-termux/default.nix b/pkgs/proot-termux/default.nix index 7a3c26d..2fc0098 100644 --- a/pkgs/proot-termux/default.nix +++ b/pkgs/proot-termux/default.nix @@ -1,7 +1,7 @@ # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. -{ pkgs, stdenv, callPackage, fetchFromGitHub, - talloc, outputBinaryName ? "proot-static" }: +{ stdenv, fetchFromGitHub, talloc, + static ? true, outputBinaryName ? "proot-static" }: stdenv.mkDerivation { pname = "proot-termux"; @@ -12,20 +12,26 @@ stdenv.mkDerivation { owner = "termux"; rev = "5c462a6ecfddd629b1439f38fbb61216d6fcb359"; sha256 = "sha256-XS4js80NsAN2C4jMuISSqMm/DwYpH/stbABaxzoqZcE="; - - # 1 step behind 6f12fbee "Implement shmat", use if ashmem.h is missing - #rev = "ffd811ee726c62094477ed335de89fc107cadf17"; - #sha256 = "1zjblclsybvsrjmq2i0z6prhka268f0609w08dh9vdrbrng117f8"; }; - buildInputs = [ talloc ]; - - patches = [ ./detranslate-empty.patch ]; - - makeFlags = [ "-Csrc" "V=1" ]; - CFLAGS = [ "-O3" ]; - - installPhase = '' - install -D -m 0755 src/proot $out/bin/${outputBinaryName} + # 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 + #include + #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) + EOF ''; + + 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}"; } diff --git a/tests/proot-test.nix b/tests/proot-test.nix index bec288e..c2c8074 100644 --- a/tests/proot-test.nix +++ b/tests/proot-test.nix @@ -1,11 +1,9 @@ -# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE. +# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. { pkgs ? (import ../pkgs/lib/load-nixpkgs.nix {}) }: -let +pkgs.callPackage ../pkgs/proot-termux { stdenv = pkgs.stdenv; -in - pkgs.callPackage ../pkgs/proot-termux { - outputBinaryName = "proot"; - inherit pkgs; - } + static = false; + outputBinaryName = "proot"; +}