mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
tests: refactor to support flake setup
This commit is contained in:
parent
004faf1835
commit
5d9e3c3dd1
6 changed files with 68 additions and 28 deletions
20
.github/workflows/fakedroid-odt.yml
vendored
20
.github/workflows/fakedroid-odt.yml
vendored
|
|
@ -21,15 +21,25 @@ jobs:
|
||||||
name: nix-on-droid
|
name: nix-on-droid
|
||||||
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
|
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
|
||||||
|
|
||||||
|
- name: Build fakedroid script
|
||||||
|
run: |
|
||||||
|
nix \
|
||||||
|
--log-format bar-with-logs \
|
||||||
|
--option keep-going true \
|
||||||
|
--show-trace \
|
||||||
|
build .#fakedroid \
|
||||||
|
--impure \
|
||||||
|
--out-link fakedroid
|
||||||
|
|
||||||
- name: Initialize fakedroid
|
- name: Initialize fakedroid
|
||||||
run: tests/fakedroid.sh echo INIT
|
run: ./fakedroid echo INIT
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
tests/fakedroid.sh mkdir -p .cache/nix-on-droid-self-test
|
./fakedroid mkdir -p .cache/nix-on-droid-self-test
|
||||||
tests/fakedroid.sh touch .cache/nix-on-droid-self-test/confirmation-granted
|
./fakedroid touch .cache/nix-on-droid-self-test/confirmation-granted
|
||||||
tests/fakedroid.sh nix-on-droid on-device-test
|
./fakedroid nix-on-droid on-device-test
|
||||||
|
|
||||||
- name: Push to cachix
|
- name: Push to cachix
|
||||||
if: always() && github.event_name != 'pull_request'
|
if: always() && github.event_name != 'pull_request'
|
||||||
run: tests/fakedroid.sh nix-shell -p cachix --run 'nix --extra-experimental-features nix-command path-info --all | cachix push nix-on-droid'
|
run: ./fakedroid nix-shell -p cachix --run 'nix --extra-experimental-features nix-command path-info --all | cachix push nix-on-droid'
|
||||||
|
|
|
||||||
15
flake.nix
15
flake.nix
|
|
@ -57,9 +57,16 @@
|
||||||
// flake-utils.lib.eachSystem [ "aarch64-linux" "i686-linux" "x86_64-darwin" "x86_64-linux" ] (system: {
|
// flake-utils.lib.eachSystem [ "aarch64-linux" "i686-linux" "x86_64-darwin" "x86_64-linux" ] (system: {
|
||||||
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
|
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
|
||||||
|
|
||||||
packages = import ./pkgs {
|
packages =
|
||||||
inherit system;
|
(import ./pkgs {
|
||||||
nixpkgs = nixpkgs-for-bootstrap;
|
inherit system;
|
||||||
};
|
nixpkgs = nixpkgs-for-bootstrap;
|
||||||
|
}).customPkgs
|
||||||
|
// {
|
||||||
|
fakedroid = import ./tests {
|
||||||
|
inherit system;
|
||||||
|
nixpkgs = nixpkgs-for-bootstrap;
|
||||||
|
};
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,15 @@ let
|
||||||
bootstrapZip = callPackage ./bootstrap-zip.nix { };
|
bootstrapZip = callPackage ./bootstrap-zip.nix { };
|
||||||
prootTermux = callPackage ./cross-compiling/proot-termux.nix { };
|
prootTermux = callPackage ./cross-compiling/proot-termux.nix { };
|
||||||
tallocStatic = callPackage ./cross-compiling/talloc-static.nix { };
|
tallocStatic = callPackage ./cross-compiling/talloc-static.nix { };
|
||||||
|
prootTermuxTest = callPackage ./proot-termux {
|
||||||
|
inherit (pkgs) stdenv;
|
||||||
|
static = false;
|
||||||
|
outputBinaryName = "proot";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
||||||
customPkgs
|
{
|
||||||
|
inherit (modules) config;
|
||||||
|
inherit customPkgs;
|
||||||
|
}
|
||||||
|
|
|
||||||
26
tests/default.nix
Normal file
26
tests/default.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
|
{ nixpkgs, system }:
|
||||||
|
|
||||||
|
let
|
||||||
|
bootstrap = import ../pkgs {
|
||||||
|
inherit nixpkgs system;
|
||||||
|
nixOnDroidChannelURL = "file:///n-o-d/archive.tar.gz";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
nixpkgs.legacyPackages.${system}.runCommand
|
||||||
|
"fakedroid"
|
||||||
|
{
|
||||||
|
preferLocalBuild = true;
|
||||||
|
allowSubstitutes = false;
|
||||||
|
}
|
||||||
|
''
|
||||||
|
install -D -m755 ${./fakedroid.sh} $out
|
||||||
|
|
||||||
|
substituteInPlace $out \
|
||||||
|
--subst-var-by bootstrapZip "${bootstrap.customPkgs.bootstrapZip}" \
|
||||||
|
--subst-var-by prootTest "${bootstrap.customPkgs.prootTermuxTest}" \
|
||||||
|
--subst-var-by installationDir "${bootstrap.config.build.installationDir}" \
|
||||||
|
--subst-var-by homeDir "${bootstrap.config.user.home}" \
|
||||||
|
''
|
||||||
16
tests/fakedroid.sh
Executable file → Normal file
16
tests/fakedroid.sh
Executable file → Normal file
|
|
@ -8,15 +8,17 @@
|
||||||
|
|
||||||
set -ueo pipefail
|
set -ueo pipefail
|
||||||
|
|
||||||
REPO_DIR="$(dirname "$(dirname "$(readlink -f "$0")")")"
|
# 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"
|
INJ_DIR="$REPO_DIR/.fakedroid/inj"
|
||||||
ENV_DIR="$REPO_DIR/.fakedroid/env"
|
ENV_DIR="$REPO_DIR/.fakedroid/env"
|
||||||
|
|
||||||
QEMU_URL="https://github.com/multiarch/qemu-user-static/releases/download/v6.1.0-8/qemu-aarch64-static"
|
QEMU_URL="https://github.com/multiarch/qemu-user-static/releases/download/v6.1.0-8/qemu-aarch64-static"
|
||||||
QEMU="$INJ_DIR/qemu-aarch64"
|
QEMU="$INJ_DIR/qemu-aarch64"
|
||||||
|
|
||||||
INSTALLATION_DIR="/data/data/com.termux.nix/files/usr"
|
INSTALLATION_DIR="@installationDir@"
|
||||||
TARGET_HOME="/data/data/com.termux.nix/files/home"
|
TARGET_HOME="@homeDir@"
|
||||||
|
|
||||||
mkdir -p "$INJ_DIR"
|
mkdir -p "$INJ_DIR"
|
||||||
mkdir -p "$ENV_DIR/"{"$INSTALLATION_DIR","$TARGET_HOME",n-o-d}
|
mkdir -p "$ENV_DIR/"{"$INSTALLATION_DIR","$TARGET_HOME",n-o-d}
|
||||||
|
|
@ -57,7 +59,7 @@ PROOT_ARGS=(
|
||||||
[[ -e "$QEMU" ]] || wget "$QEMU_URL" -O "$QEMU"
|
[[ -e "$QEMU" ]] || wget "$QEMU_URL" -O "$QEMU"
|
||||||
chmod +x "$QEMU"
|
chmod +x "$QEMU"
|
||||||
|
|
||||||
PROOT="$(nix-build --no-out-link tests/proot-test.nix)/bin/proot"
|
PROOT="@prootTest@/bin/proot"
|
||||||
|
|
||||||
|
|
||||||
# Do the first install if not installed yet:
|
# Do the first install if not installed yet:
|
||||||
|
|
@ -65,11 +67,7 @@ PROOT="$(nix-build --no-out-link tests/proot-test.nix)/bin/proot"
|
||||||
if [[ ! -e "$ENV_DIR/$INSTALLATION_DIR/etc" ||
|
if [[ ! -e "$ENV_DIR/$INSTALLATION_DIR/etc" ||
|
||||||
-e "$ENV_DIR/$INSTALLATION_DIR/etc/UNINITIALIZED" ]]; then
|
-e "$ENV_DIR/$INSTALLATION_DIR/etc/UNINITIALIZED" ]]; then
|
||||||
# Build a zipball:
|
# Build a zipball:
|
||||||
nix build --show-trace -f pkgs \
|
ZIPBALL="@bootstrapZip@/bootstrap-aarch64.zip"
|
||||||
--argstr arch aarch64 \
|
|
||||||
--argstr nixOnDroidChannelURL file:///n-o-d/archive.tar.gz \
|
|
||||||
bootstrapZip -o "$INJ_DIR/nix-on-droid-aarch64"
|
|
||||||
ZIPBALL="$(realpath "$INJ_DIR/nix-on-droid-aarch64/bootstrap-aarch64.zip")"
|
|
||||||
# Unpack the zipball the way the Android app does it:
|
# Unpack the zipball the way the Android app does it:
|
||||||
pushd "$ENV_DIR/$INSTALLATION_DIR"
|
pushd "$ENV_DIR/$INSTALLATION_DIR"
|
||||||
unzip "$ZIPBALL"
|
unzip "$ZIPBALL"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
|
||||||
|
|
||||||
{ pkgs ? (import ../pkgs/lib/load-nixpkgs.nix { }) }:
|
|
||||||
|
|
||||||
pkgs.callPackage ../pkgs/proot-termux {
|
|
||||||
inherit (pkgs) stdenv;
|
|
||||||
static = false;
|
|
||||||
outputBinaryName = "proot";
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue