Compare commits

..

2 commits

Author SHA1 Message Date
Shelvacu
27696cac81 Add tests for _class="nixOnDroid"
Some checks failed
Build bootstrap packages and push to cachix / cachix (push) Has been cancelled
Build and deploy docs / deploy (push) Has been cancelled
Test nix-on-droid in an emulator / prepare-droidctl (push) Has been cancelled
Test nix-on-droid in an emulator / prepare-n-o-d (push) Has been cancelled
Test nix-on-droid in an emulator / prepare-avd (29) (push) Has been cancelled
Run lints / lint (push) Has been cancelled
Test nix-on-droid in an emulator / emulate (29, android_integration) (push) Has been cancelled
Test nix-on-droid in an emulator / emulate (29, bootstrap_channels) (push) Has been cancelled
Test nix-on-droid in an emulator / emulate (29, bootstrap_flakes) (push) Has been cancelled
Test nix-on-droid in an emulator / emulate (29, poke_around) (push) Has been cancelled
Test nix-on-droid in an emulator / emulate (29, test_channels_shell) (push) Has been cancelled
Test nix-on-droid in an emulator / emulate (29, test_channels_uiautomator) (push) Has been cancelled
2025-07-21 14:28:15 +02:00
Shelvacu
a25bb0ab27 Pass class="nixOnDroid"; to evalModules
This is useful for getting better error messages when mixing modules; a module designed for nixos configs sets `_class = "nixos";` and then when you try to use it from a nix-on-droid config it shows an error.

See: https://nixos.org/manual/nixpkgs/unstable/#module-system-lib-evalModules-param-class
2025-07-21 14:28:15 +02:00
2 changed files with 26 additions and 0 deletions

View file

@ -25,6 +25,7 @@ let
rawModule = evalModules {
modules = [ configModule ] ++ nodModules;
specialArgs = extraSpecialArgs;
class = "nixOnDroid";
};
failedAssertions = map (x: x.message) (filter (x: !x.assertion) rawModule.config.assertions);

View file

@ -0,0 +1,25 @@
# Copyright (c) 2023, see AUTHORS. Licensed under MIT License, see LICENSE.
load lib
@test 'successfully loads a config with _class="nixOnDroid"' {
# set up / build / activate the configuration
echo '{ config.system.stateVersion = "24.05"; _class = "nixOnDroid"; }' > ~/.config/nixpkgs/nix-on-droid.nix
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
> ~/.config/nixpkgs/flake.nix
nix-on-droid switch --flake ~/.config/nixpkgs#device
}
@test 'fails to load a config with _class="nixos"' {
# set up / build / activate the configuration
echo '{ config.system.stateVersion = "24.05"; _class = "nixos"; }' > ~/.config/nixpkgs/nix-on-droid.nix
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
> ~/.config/nixpkgs/flake.nix
# check that networking.hosts can't map localhost
run nix-on-droid switch --flake ~/.config/nixpkgs#device
[ "$status" -eq 1 ]
}