mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
add support for default configuration in flake.nix
This commit is contained in:
parent
8cb7a6c670
commit
b06c9705a7
9 changed files with 51 additions and 13 deletions
|
|
@ -21,6 +21,9 @@
|
||||||
and `config` and `extraModules` are now combined into `modules`
|
and `config` and `extraModules` are now combined into `modules`
|
||||||
* Add option `environment.motd` to edit the startup message that is printed in
|
* Add option `environment.motd` to edit the startup message that is printed in
|
||||||
every shell
|
every shell
|
||||||
|
* For flake setups, the output `nixOnDroidConfigurations.default` will be used
|
||||||
|
when `nix-on-droid switch --flake path/to/flake` is called without attribute
|
||||||
|
name
|
||||||
|
|
||||||
## Release 22.05
|
## Release 22.05
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ A minimal example could look like the following:
|
||||||
|
|
||||||
outputs = { self, nixpkgs, nix-on-droid }: {
|
outputs = { self, nixpkgs, nix-on-droid }: {
|
||||||
|
|
||||||
nixOnDroidConfigurations.deviceName = nix-on-droid.lib.nixOnDroidConfiguration {
|
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||||
modules = [ ./nix-on-droid.nix ];
|
modules = [ ./nix-on-droid.nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -208,8 +208,9 @@ nix flake init --template github:t184256/nix-on-droid#advanced
|
||||||
|
|
||||||
### Usage with `nix-on-droid`
|
### Usage with `nix-on-droid`
|
||||||
|
|
||||||
Use `nix-on-droid switch --flake .#device` to build and activate your configuration (`.#device` will expand to
|
Use `nix-on-droid switch --flake path/to/flake#device` to build and activate your configuration (`path/to/flake#device`
|
||||||
`.#nixOnDroidConfigurations.device`).
|
will expand to `.#nixOnDroidConfigurations.device`). If you run `nix-on-droid switch --flake path/to/flake`, the
|
||||||
|
`default` configuration will be used.
|
||||||
|
|
||||||
**Note:** Currently, nix-on-droid can not be built with an pure flake build because of hardcoded store paths for proot.
|
**Note:** Currently, nix-on-droid can not be built with an pure flake build because of hardcoded store paths for proot.
|
||||||
Therefore, every evaluation of a flake configuration will be executed with `--impure` flag. (This behaviour will be
|
Therefore, every evaluation of a flake configuration will be executed with `--impure` flag. (This behaviour will be
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ writeText "login-inner" ''
|
||||||
''}
|
''}
|
||||||
|
|
||||||
echo "Installing first nix-on-droid generation..."
|
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
|
${nixCmd} run ${config.build.flake.nix-on-droid} -- switch --flake ${config.user.home}/.config/nix-on-droid
|
||||||
|
|
||||||
. "${config.user.home}/.nix-profile/etc/profile.d/nix-on-droid-session-init.sh"
|
. "${config.user.home}/.nix-profile/etc/profile.d/nix-on-droid-session-init.sh"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,8 @@ function doHelp() {
|
||||||
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 " -F|--flake FLAKE Path to flake and device name (e.g. path/to/flake#device),"
|
||||||
|
echo " device 'default' will be used if no attribute name is given"
|
||||||
echo
|
echo
|
||||||
echo "Options passed on to nix build"
|
echo "Options passed on to nix build"
|
||||||
echo
|
echo
|
||||||
|
|
@ -139,7 +140,12 @@ while [[ $# -gt 0 ]]; do
|
||||||
PASSTHROUGH_OPTS+=(--extra-experimental-features "flakes nix-command")
|
PASSTHROUGH_OPTS+=(--extra-experimental-features "flakes nix-command")
|
||||||
# add "nixOnDroidConfigurations." as prefix in attribute name, e.g.
|
# add "nixOnDroidConfigurations." as prefix in attribute name, e.g.
|
||||||
# /path/to/flake#device -> /path/to/flake#nixOnDroidConfigurations.device
|
# /path/to/flake#device -> /path/to/flake#nixOnDroidConfigurations.device
|
||||||
FLAKE_CONFIG_URI="${1%#*}#nixOnDroidConfigurations.${1#*#}"
|
# if no attribute name given, use "default"
|
||||||
|
if [[ "$1" =~ \# ]]; then
|
||||||
|
FLAKE_CONFIG_URI="${1%#*}#nixOnDroidConfigurations.${1#*#}"
|
||||||
|
else
|
||||||
|
FLAKE_CONFIG_URI="${1}#nixOnDroidConfigurations.default"
|
||||||
|
fi
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
outputs = { self, nixpkgs, home-manager, nix-on-droid }: {
|
outputs = { self, nixpkgs, home-manager, nix-on-droid }: {
|
||||||
|
|
||||||
nixOnDroidConfigurations.deviceName = nix-on-droid.lib.nixOnDroidConfiguration {
|
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||||
modules = [
|
modules = [
|
||||||
./nix-on-droid.nix
|
./nix-on-droid.nix
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
outputs = { self, nixpkgs, home-manager, nix-on-droid }: {
|
outputs = { self, nixpkgs, home-manager, nix-on-droid }: {
|
||||||
|
|
||||||
nixOnDroidConfigurations.deviceName = nix-on-droid.lib.nixOnDroidConfiguration {
|
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||||
modules = [ ./nix-on-droid.nix ];
|
modules = [ ./nix-on-droid.nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
outputs = { self, nixpkgs, nix-on-droid }: {
|
outputs = { self, nixpkgs, nix-on-droid }: {
|
||||||
|
|
||||||
nixOnDroidConfigurations.deviceName = nix-on-droid.lib.nixOnDroidConfiguration {
|
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||||
modules = [ ./nix-on-droid.nix ];
|
modules = [ ./nix-on-droid.nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
17
tests/on-device/config-flake-default.nix
Normal file
17
tests/on-device/config-flake-default.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
description = "nix-on-droid configuration";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/release-22.05";
|
||||||
|
nix-on-droid.url = "<<FLAKE_URL>>";
|
||||||
|
nix-on-droid.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nix-on-droid, ... }: {
|
||||||
|
nixOnDroidConfigurations = {
|
||||||
|
default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||||
|
modules = [ ./nix-on-droid.nix ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
load lib
|
load lib
|
||||||
|
|
||||||
@test 'flake example works' {
|
function flake_example() {
|
||||||
|
local flake_url="$1"
|
||||||
|
local flake_file_name="$2"
|
||||||
|
|
||||||
# assertions to verify initial state is as expected
|
# assertions to verify initial state is as expected
|
||||||
assert_command vi
|
assert_command vi
|
||||||
assert_no_command unzip
|
assert_no_command unzip
|
||||||
|
|
@ -15,10 +18,10 @@ load lib
|
||||||
> ~/.config/nixpkgs/nix-on-droid.nix
|
> ~/.config/nixpkgs/nix-on-droid.nix
|
||||||
|
|
||||||
_sed "s|<<FLAKE_URL>>|$FLAKE_URL|g" \
|
_sed "s|<<FLAKE_URL>>|$FLAKE_URL|g" \
|
||||||
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
|
"$ON_DEVICE_TESTS_DIR/$flake_file_name" \
|
||||||
> ~/.config/nixpkgs/flake.nix
|
> ~/.config/nixpkgs/flake.nix
|
||||||
|
|
||||||
nix-on-droid switch --flake ~/.config/nixpkgs#device
|
nix-on-droid switch --flake "$flake_url"
|
||||||
|
|
||||||
# test presence of several crucial commands
|
# test presence of several crucial commands
|
||||||
assert_command nix-on-droid nix-shell bash
|
assert_command nix-on-droid nix-shell bash
|
||||||
|
|
@ -32,3 +35,11 @@ load lib
|
||||||
assert_command vi
|
assert_command vi
|
||||||
assert_no_command unzip
|
assert_no_command unzip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test 'flake example works' {
|
||||||
|
flake_example ~/.config/nixpkgs#device config-flake.nix
|
||||||
|
}
|
||||||
|
|
||||||
|
@test 'flake with default config works' {
|
||||||
|
flake_example ~/.config/nixpkgs config-flake-default.nix
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue