mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
nix-on-droid: add native support for flakes
This commit is contained in:
parent
c0568ad13a
commit
3d3441de44
2 changed files with 33 additions and 20 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ bash, coreutils, nix, runCommand }:
|
{ bash, coreutils, nix, nix_2_4, runCommand }:
|
||||||
|
|
||||||
runCommand
|
runCommand
|
||||||
"nix-on-droid"
|
"nix-on-droid"
|
||||||
|
|
@ -14,5 +14,6 @@ runCommand
|
||||||
substituteInPlace $out/bin/nix-on-droid \
|
substituteInPlace $out/bin/nix-on-droid \
|
||||||
--subst-var-by bash "${bash}" \
|
--subst-var-by bash "${bash}" \
|
||||||
--subst-var-by coreutils "${coreutils}" \
|
--subst-var-by coreutils "${coreutils}" \
|
||||||
--subst-var-by nix "${nix}"
|
--subst-var-by nix "${nix}" \
|
||||||
|
--subst-var-by nix24 "${nix_2_4}"
|
||||||
''
|
''
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,24 @@ function setupPasstroughOpts() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nixActivationPackage() {
|
||||||
|
local command="$1"
|
||||||
|
local extraArgs=("${@:2}" "${PASSTHROUGH_OPTS[@]}")
|
||||||
|
local nix=nix
|
||||||
|
if [[ -n "${FLAKE_CONFIG_URI}" ]]; then
|
||||||
|
nix=@nix24@/bin/nix
|
||||||
|
extraArgs+=(--impure "${FLAKE_CONFIG_URI}.activationPackage")
|
||||||
|
else
|
||||||
|
extraArgs+=(--file "<nix-on-droid/modules>" activationPackage)
|
||||||
|
fi
|
||||||
|
|
||||||
|
$nix "${command}" "${extraArgs[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function doBuild() {
|
function doBuild() {
|
||||||
echo "Building activation package..."
|
echo "Building activation package..."
|
||||||
nix build \
|
nixActivationPackage build
|
||||||
--file "<nix-on-droid/modules>" \
|
|
||||||
${PASSTHROUGH_OPTS[*]} \
|
|
||||||
activationPackage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function doGenerations() {
|
function doGenerations() {
|
||||||
|
|
@ -41,10 +52,11 @@ function doHelp() {
|
||||||
echo
|
echo
|
||||||
echo "Options"
|
echo "Options"
|
||||||
echo
|
echo
|
||||||
echo " -h|--help Print this help"
|
echo " -h|--help Print this help"
|
||||||
echo " -n|--dry-run Do a dry run, only prints what actions would be taken"
|
echo " -n|--dry-run Do a dry run, only prints what actions would be taken"
|
||||||
echo " -v|--verbose Verbose output"
|
echo " -v|--verbose Verbose output"
|
||||||
echo " -f|--file FILE Path to config file"
|
echo " -f|--file FILE Path to config file"
|
||||||
|
echo " -F|--flake FLAKE Path to flake and device name (e.g. path/to/flake#device)"
|
||||||
echo
|
echo
|
||||||
echo "Options passed on to nix build"
|
echo "Options passed on to nix build"
|
||||||
echo
|
echo
|
||||||
|
|
@ -82,18 +94,10 @@ function doOnDeviceTest() {
|
||||||
|
|
||||||
function doSwitch() {
|
function doSwitch() {
|
||||||
echo "Building activation package..."
|
echo "Building activation package..."
|
||||||
nix build \
|
nixActivationPackage build --no-link
|
||||||
--no-link \
|
|
||||||
--file "<nix-on-droid/modules>" \
|
|
||||||
${PASSTHROUGH_OPTS[*]} \
|
|
||||||
activationPackage
|
|
||||||
|
|
||||||
echo "Executing activation script..."
|
echo "Executing activation script..."
|
||||||
generationDir="$(nix path-info \
|
generationDir="$(nixActivationPackage path-info)"
|
||||||
--file "<nix-on-droid/modules>" \
|
|
||||||
${PASSTHROUGH_OPTS[*]} \
|
|
||||||
activationPackage \
|
|
||||||
)"
|
|
||||||
|
|
||||||
"${generationDir}/activate"
|
"${generationDir}/activate"
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +119,7 @@ function doSwitchGeneration() {
|
||||||
COMMAND_ARGS=()
|
COMMAND_ARGS=()
|
||||||
COMMAND=
|
COMMAND=
|
||||||
CONFIG_FILE=
|
CONFIG_FILE=
|
||||||
|
FLAKE_CONFIG_URI=
|
||||||
PASSTHROUGH_OPTS=()
|
PASSTHROUGH_OPTS=()
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
|
@ -128,6 +133,13 @@ while [[ $# -gt 0 ]]; do
|
||||||
CONFIG_FILE="$1"
|
CONFIG_FILE="$1"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-F|--flake)
|
||||||
|
PASSTHROUGH_OPTS+=(--extra-experimental-features flakes --extra-experimental-features nix-command)
|
||||||
|
# add "nixOnDroidConfigurations." as prefix in attribute name, e.g.
|
||||||
|
# /path/to/flake#device -> /path/to/flake#nixOnDroidConfigurations.device
|
||||||
|
FLAKE_CONFIG_URI="${1%#*}#nixOnDroidConfigurations.${1#*#}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
doHelp
|
doHelp
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue