mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
Whenever Nix-on-Droid references the project or application it should be upper-cased. When nix-on-droid is referencing the CLI-tool or is used as some ID, it should be lower-cased.
63 lines
1.9 KiB
Nix
63 lines
1.9 KiB
Nix
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
|
|
|
{ config, writeScript, writeText }:
|
|
|
|
let
|
|
inherit (config.build) installationDir extraProotOptions;
|
|
fakeProcStat = writeText "fakeProcStat" ''
|
|
btime 0
|
|
'';
|
|
fakeProcUptime = writeText "fakeProcUptime" ''
|
|
0.00 0.00
|
|
'';
|
|
in
|
|
|
|
writeScript "login" ''
|
|
#!/system/bin/sh
|
|
# This file is generated by Nix-on-Droid. DO NOT EDIT.
|
|
set -eu -o pipefail
|
|
|
|
export USER="${config.user.userName}"
|
|
export HOME="${config.user.home}"
|
|
export PROOT_TMP_DIR=${installationDir}/tmp
|
|
export PROOT_L2S_DIR=${installationDir}/.l2s
|
|
|
|
if ! /system/bin/pgrep proot-static > /dev/null; then
|
|
if test -e ${installationDir}/bin/.proot-static.new; then
|
|
echo "Installing new proot-static..."
|
|
/system/bin/mv ${installationDir}/bin/.proot-static.new ${installationDir}/bin/proot-static
|
|
fi
|
|
|
|
if test -e ${installationDir}/usr/lib/.login-inner.new; then
|
|
echo "Installing new login-inner..."
|
|
/system/bin/mv ${installationDir}/usr/lib/.login-inner.new ${installationDir}/usr/lib/login-inner
|
|
fi
|
|
fi
|
|
|
|
if [ ! -r /proc/stat ] && [ -e ${installationDir}${fakeProcStat} ]; then
|
|
BIND_PROC_STAT="-b ${installationDir}${fakeProcStat}:/proc/stat"
|
|
else
|
|
BIND_PROC_STAT=""
|
|
fi
|
|
|
|
if [ ! -r /proc/uptime ] && [ -e ${installationDir}${fakeProcUptime} ]; then
|
|
BIND_PROC_UPTIME="-b ${installationDir}${fakeProcUptime}:/proc/uptime"
|
|
else
|
|
BIND_PROC_UPTIME=""
|
|
fi
|
|
|
|
exec ${installationDir}/bin/proot-static \
|
|
-b ${installationDir}/nix:/nix \
|
|
-b ${installationDir}/bin:/bin \
|
|
-b ${installationDir}/etc:/etc \
|
|
-b ${installationDir}/tmp:/tmp \
|
|
-b ${installationDir}/usr:/usr \
|
|
-b ${installationDir}/dev/shm:/dev/shm \
|
|
$BIND_PROC_STAT \
|
|
$BIND_PROC_UPTIME \
|
|
-b /:/android \
|
|
--link2symlink \
|
|
--sysvipc \
|
|
${builtins.concatStringsSep " " extraProotOptions} \
|
|
${installationDir}/bin/sh ${installationDir}/usr/lib/login-inner "$@"
|
|
''
|