mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
Add possibility to use fakedroid from outside the repo
This commit is contained in:
parent
2301e01d48
commit
d7efa68f7c
3 changed files with 13 additions and 9 deletions
|
|
@ -239,6 +239,12 @@ with the command as arguments:
|
|||
nix run --impure ".#fakedroid" -- ls -l
|
||||
```
|
||||
|
||||
To override the default state directory of fakedroid (`$PWD/.fakedroid`), call it with `STATE_DIR`:
|
||||
|
||||
```sh
|
||||
STATE_DIR=path/to/local/dir nix run --impure github:t184256/nix-on-droid#fakedroid
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
In the [./tests/on-device](./tests/on-device) directory, there is small set
|
||||
|
|
|
|||
|
|
@ -38,4 +38,5 @@ pkgs.runCommand
|
|||
--subst-var-by prootTest "${bootstrap.customPkgs.prootTermuxTest}" \
|
||||
--subst-var-by installationDir "${bootstrap.config.build.installationDir}" \
|
||||
--subst-var-by homeDir "${bootstrap.config.user.home}" \
|
||||
--subst-var-by flakeRootDir "${toString ../.}"
|
||||
''
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
set -ueo pipefail
|
||||
|
||||
PATH=@path@
|
||||
FLAKE_ROOT_DIR=@flakeRootDir@
|
||||
STATE_DIR="${STATE_DIR:-"$(pwd)/.fakedroid"}"
|
||||
|
||||
USE_FLAKE="${USE_FLAKE:-0}"
|
||||
if [[ ! "$USE_FLAKE" =~ ^[01]$ ]]; then
|
||||
|
|
@ -16,11 +18,8 @@ if [[ ! "$USE_FLAKE" =~ ^[01]$ ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# this allows to run this script from every place in this git repo
|
||||
REPO_DIR="$(git rev-parse --show-toplevel)"
|
||||
|
||||
INJ_DIR="$REPO_DIR/.fakedroid/inj"
|
||||
ENV_DIR="$REPO_DIR/.fakedroid/env/$USE_FLAKE"
|
||||
INJ_DIR="$STATE_DIR/inj"
|
||||
ENV_DIR="$STATE_DIR/env/$USE_FLAKE"
|
||||
|
||||
QEMU_URL="https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-aarch64-static"
|
||||
QEMU="$INJ_DIR/qemu-aarch64"
|
||||
|
|
@ -100,10 +99,8 @@ fi
|
|||
|
||||
rm -rf "$ENV_DIR/n-o-d"
|
||||
mkdir -p "$ENV_DIR/n-o-d/unpacked"
|
||||
git -C "$REPO_DIR" archive --format=tar --prefix n-o-d/ HEAD \
|
||||
> "$ENV_DIR/n-o-d/archive.tar"
|
||||
tar --strip-components=1 -xf \
|
||||
"$ENV_DIR/n-o-d/archive.tar" -C "$ENV_DIR/n-o-d/unpacked"
|
||||
tar -cf "$ENV_DIR/n-o-d/archive.tar" --mode='u+w' -C "$FLAKE_ROOT_DIR" --transform 's,^,n-o-d/,' .
|
||||
tar --strip-components=1 -xf "$ENV_DIR/n-o-d/archive.tar" -C "$ENV_DIR/n-o-d/unpacked"
|
||||
gzip "$ENV_DIR/n-o-d/archive.tar"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue