mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
bootstrap: add prompt to bootstrap with flakes setup
This commit is contained in:
parent
5900404627
commit
c0b87d967f
4 changed files with 109 additions and 24 deletions
38
.github/workflows/fakedroid-odt.yml
vendored
38
.github/workflows/fakedroid-odt.yml
vendored
|
|
@ -3,7 +3,7 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
jobs:
|
jobs:
|
||||||
fakedroid-odt:
|
fakedroid-odt-channel:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -31,7 +31,7 @@ jobs:
|
||||||
--impure \
|
--impure \
|
||||||
--out-link fakedroid
|
--out-link fakedroid
|
||||||
|
|
||||||
- name: Initialize fakedroid
|
- name: Initialize fakedroid for channel setup
|
||||||
run: ./fakedroid echo INIT
|
run: ./fakedroid echo INIT
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|
@ -43,3 +43,37 @@ jobs:
|
||||||
- name: Push to cachix
|
- name: Push to cachix
|
||||||
if: always() && github.event_name != 'pull_request'
|
if: always() && github.event_name != 'pull_request'
|
||||||
run: ./fakedroid 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'
|
||||||
|
|
||||||
|
|
||||||
|
fakedroid-flakes:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install nix
|
||||||
|
uses: cachix/install-nix-action@v18
|
||||||
|
|
||||||
|
- name: Setup cachix
|
||||||
|
uses: cachix/cachix-action@v12
|
||||||
|
with:
|
||||||
|
name: nix-on-droid
|
||||||
|
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 for flake setup
|
||||||
|
run: USE_FLAKE=1 ./fakedroid echo INIT
|
||||||
|
|
||||||
|
- name: Push to cachix
|
||||||
|
if: always() && github.event_name != 'pull_request'
|
||||||
|
run: ./fakedroid nix-shell -p cachix --run 'nix --extra-experimental-features nix-command path-info --all | cachix push nix-on-droid'
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@
|
||||||
device, but bootstrap zip ball creation and running tests via fakedroid
|
device, but bootstrap zip ball creation and running tests via fakedroid
|
||||||
requires flake setup)
|
requires flake setup)
|
||||||
* Add support for `nix profile` managed profiles
|
* Add support for `nix profile` managed profiles
|
||||||
|
* Add possibilty to bootstrap Nix-on-Droid with flakes via prompt on initial
|
||||||
|
boot
|
||||||
|
|
||||||
## Release 22.05
|
## Release 22.05
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (initialPackageInfo) cacert nix;
|
inherit (initialPackageInfo) cacert nix;
|
||||||
|
|
||||||
|
nixCmd = "${nix}/bin/nix --extra-experimental-features flakes --extra-experimental-features nix-command";
|
||||||
in
|
in
|
||||||
|
|
||||||
writeText "login-inner" ''
|
writeText "login-inner" ''
|
||||||
|
|
@ -32,37 +34,77 @@ writeText "login-inner" ''
|
||||||
|
|
||||||
export NIX_SSL_CERT_FILE=${cacert}
|
export NIX_SSL_CERT_FILE=${cacert}
|
||||||
|
|
||||||
echo "Installing and updating nix-channels..."
|
echo
|
||||||
${nix}/bin/nix-channel --add ${config.build.channel.nixpkgs} nixpkgs
|
echo "Nix-on-Droid can be set up with channels or with flakes (still experimental)."
|
||||||
${nix}/bin/nix-channel --update nixpkgs
|
while [[ -z $USE_FLAKE ]]; do
|
||||||
${nix}/bin/nix-channel --add ${config.build.channel.nix-on-droid} nix-on-droid
|
read -r -p "Do you want to set it up with flakes? (y/N) " flakes
|
||||||
${nix}/bin/nix-channel --update nix-on-droid
|
|
||||||
|
|
||||||
DEFAULT_CONFIG=$(${nix}/bin/nix-instantiate --eval --expr "<nix-on-droid/modules/environment/login/nix-on-droid.nix.default>")
|
if [[ "$flakes" =~ ^[Yy]$ ]]; then
|
||||||
|
USE_FLAKE=1
|
||||||
|
elif [[ "$flakes" =~ ^[Nn]$ ]]; then
|
||||||
|
USE_FLAKE=0
|
||||||
|
else
|
||||||
|
echo "Received invalid input, please try again. $flakes"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "Installing first nix-on-droid generation..."
|
if [[ "$USE_FLAKE" == 0 ]]; then
|
||||||
${nix}/bin/nix --extra-experimental-features nix-command \
|
|
||||||
build --no-link --file "<nix-on-droid>" nix-on-droid
|
|
||||||
$(${nix}/bin/nix --extra-experimental-features nix-command \
|
|
||||||
path-info --file "<nix-on-droid>" nix-on-droid)/bin/nix-on-droid switch -f $DEFAULT_CONFIG
|
|
||||||
|
|
||||||
. "${config.user.home}/.nix-profile/etc/profile.d/nix-on-droid-session-init.sh"
|
echo "Setting up Nix-on-Droid with channels..."
|
||||||
|
|
||||||
echo "Copying default nix-on-droid config..."
|
echo "Installing and updating nix-channels..."
|
||||||
mkdir --parents $HOME/.config/nixpkgs
|
${nix}/bin/nix-channel --add ${config.build.channel.nixpkgs} nixpkgs
|
||||||
cp $DEFAULT_CONFIG $HOME/.config/nixpkgs/nix-on-droid.nix
|
${nix}/bin/nix-channel --update nixpkgs
|
||||||
chmod u+w $HOME/.config/nixpkgs/nix-on-droid.nix
|
${nix}/bin/nix-channel --add ${config.build.channel.nix-on-droid} nix-on-droid
|
||||||
|
${nix}/bin/nix-channel --update nix-on-droid
|
||||||
|
|
||||||
|
DEFAULT_CONFIG=$(${nix}/bin/nix-instantiate --eval --expr "<nix-on-droid/modules/environment/login/nix-on-droid.nix.default>")
|
||||||
|
|
||||||
|
echo "Installing first nix-on-droid generation..."
|
||||||
|
${nixCmd} build --no-link --file "<nix-on-droid>" nix-on-droid
|
||||||
|
$(${nixCmd} path-info --file "<nix-on-droid>" nix-on-droid)/bin/nix-on-droid switch --file $DEFAULT_CONFIG
|
||||||
|
|
||||||
|
. "${config.user.home}/.nix-profile/etc/profile.d/nix-on-droid-session-init.sh"
|
||||||
|
|
||||||
|
echo "Copying default nix-on-droid config..."
|
||||||
|
mkdir --parents $HOME/.config/nixpkgs
|
||||||
|
cp $DEFAULT_CONFIG $HOME/.config/nixpkgs/nix-on-droid.nix
|
||||||
|
chmod u+w $HOME/.config/nixpkgs/nix-on-droid.nix
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
echo "Setting up Nix-on-Droid with flakes..."
|
||||||
|
|
||||||
|
echo "Installing flake from default template..."
|
||||||
|
${nixCmd} flake new ${config.user.home}/.config/nix-on-droid --template ${config.build.flake.nix-on-droid}
|
||||||
|
|
||||||
|
echo "Installing first nix-on-droid generation..."
|
||||||
|
${nixCmd} run ${config.build.flake.nix-on-droid} -- switch --flake ${config.user.home}/.config/nix-on-droid#deviceName
|
||||||
|
|
||||||
|
. "${config.user.home}/.nix-profile/etc/profile.d/nix-on-droid-session-init.sh"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Congratulations! Now you have Nix installed with some default packages like bashInteractive, \
|
echo "Congratulations! Now you have Nix installed with some default packages like bashInteractive, \
|
||||||
coreutils, cacert and, most importantly, nix-on-droid itself to manage local configuration, see"
|
coreutils, cacert and, most importantly, nix-on-droid itself to manage local configuration, see"
|
||||||
echo " nix-on-droid help"
|
echo " nix-on-droid help"
|
||||||
echo "or in the config file"
|
|
||||||
echo " ~/.config/nixpkgs/nix-on-droid.nix"
|
if [[ "$USE_FLAKE" == 0 ]]; then
|
||||||
echo
|
echo "or the config file"
|
||||||
echo "You can go for the bare nix-on-droid setup or you can configure your phone via home-manager. See \
|
echo " ~/.config/nixpkgs/nix-on-droid.nix"
|
||||||
|
echo
|
||||||
|
echo "You can go for the bare nix-on-droid setup or you can configure your phone via home-manager. See \
|
||||||
config file for further information."
|
config file for further information."
|
||||||
echo
|
echo
|
||||||
|
else
|
||||||
|
echo "or the flake"
|
||||||
|
echo " ~/.config/nix-on-droid/"
|
||||||
|
echo
|
||||||
|
echo "You can go for the bare nix-on-droid setup or you can configure your phone via home-manager. See \
|
||||||
|
other templates in ${config.build.flake.nix-on-droid}."
|
||||||
|
echo
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,17 @@
|
||||||
|
|
||||||
set -ueo pipefail
|
set -ueo pipefail
|
||||||
|
|
||||||
|
USE_FLAKE="${USE_FLAKE:-0}"
|
||||||
|
if [[ ! "$USE_FLAKE" =~ ^[01]$ ]]; then
|
||||||
|
echo "USE_FLAKE environment variable needs to be either 0 or 1, got '$USE_FLAKE'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# this allows to run this script from every place in this git repo
|
# this allows to run this script from every place in this git repo
|
||||||
REPO_DIR="$(git rev-parse --show-toplevel)"
|
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/$USE_FLAKE"
|
||||||
|
|
||||||
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"
|
||||||
|
|
@ -33,6 +39,7 @@ PASSTHROUGH_VARS=(
|
||||||
"TERM=$TERM"
|
"TERM=$TERM"
|
||||||
"HOME=$TARGET_HOME"
|
"HOME=$TARGET_HOME"
|
||||||
"USER=$USER"
|
"USER=$USER"
|
||||||
|
"USE_FLAKE=$USE_FLAKE"
|
||||||
)
|
)
|
||||||
|
|
||||||
[[ -n "${CACHIX_SIGNING_KEY:-}" ]] && \
|
[[ -n "${CACHIX_SIGNING_KEY:-}" ]] && \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue