From a05928d7fed88bea451eb865a122197a4aed4e3a Mon Sep 17 00:00:00 2001 From: Hadi Date: Wed, 1 Feb 2023 17:52:02 -0500 Subject: [PATCH] androidenv: make `nix-build -A androidenv.test-suite` work androidenv: set config.allowUnfree = true for integration tests androidenv: fix concerns in the PR --- .../androidenv/compose-android-packages.nix | 6 +++++- pkgs/development/mobile/androidenv/default.nix | 2 +- .../androidenv/examples/shell-with-emulator.nix | 3 ++- .../mobile/androidenv/examples/shell.nix | 3 ++- pkgs/development/mobile/androidenv/test-suite.nix | 15 ++++++++------- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/pkgs/development/mobile/androidenv/compose-android-packages.nix b/pkgs/development/mobile/androidenv/compose-android-packages.nix index ce08de7db6d4..8c24b10093be 100644 --- a/pkgs/development/mobile/androidenv/compose-android-packages.nix +++ b/pkgs/development/mobile/androidenv/compose-android-packages.nix @@ -312,7 +312,11 @@ rec { You must accept the following licenses: ${lib.concatMapStringsSep "\n" (str: " - ${str}") licenseNames} - by setting nixpkgs config option 'android_sdk.accept_license = true;'. + a) + by setting nixpkgs config option 'android_sdk.accept_license = true;'. + b) + by an environment variable for a single invocation of the nix tools. + $ export NIXPKGS_ACCEPT_ANDROID_SDK_LICENSE=1 '' else callPackage ./cmdline-tools.nix { inherit deployAndroidPackage os cmdLineToolsVersion; diff --git a/pkgs/development/mobile/androidenv/default.nix b/pkgs/development/mobile/androidenv/default.nix index 9bd9fb9a543b..3de6bf6e478c 100644 --- a/pkgs/development/mobile/androidenv/default.nix +++ b/pkgs/development/mobile/androidenv/default.nix @@ -1,5 +1,5 @@ { config, pkgs ? import {} -, licenseAccepted ? config.android_sdk.accept_license or false +, licenseAccepted ? config.android_sdk.accept_license or (builtins.getEnv "NIXPKGS_ACCEPT_ANDROID_SDK_LICENSE" == "1") }: rec { diff --git a/pkgs/development/mobile/androidenv/examples/shell-with-emulator.nix b/pkgs/development/mobile/androidenv/examples/shell-with-emulator.nix index b9ebe844a01a..ebfe97b856ad 100644 --- a/pkgs/development/mobile/androidenv/examples/shell-with-emulator.nix +++ b/pkgs/development/mobile/androidenv/examples/shell-with-emulator.nix @@ -46,7 +46,8 @@ let # Otherwise, just use the in-tree androidenv: androidEnv = pkgs.callPackage ./.. { inherit config pkgs; - licenseAccepted = true; + # You probably need to uncomment below line to express consent. + # licenseAccepted = true; }; sdkArgs = { diff --git a/pkgs/development/mobile/androidenv/examples/shell.nix b/pkgs/development/mobile/androidenv/examples/shell.nix index 5f821af14374..775f69bce4c5 100644 --- a/pkgs/development/mobile/androidenv/examples/shell.nix +++ b/pkgs/development/mobile/androidenv/examples/shell.nix @@ -56,7 +56,8 @@ let # Otherwise, just use the in-tree androidenv: androidEnv = pkgs.callPackage ./.. { inherit config pkgs; - licenseAccepted = true; + # You probably need to uncomment below line to express consent. + # licenseAccepted = true; }; androidComposition = androidEnv.composeAndroidPackages { diff --git a/pkgs/development/mobile/androidenv/test-suite.nix b/pkgs/development/mobile/androidenv/test-suite.nix index 725858e57f28..b5aeca432461 100644 --- a/pkgs/development/mobile/androidenv/test-suite.nix +++ b/pkgs/development/mobile/androidenv/test-suite.nix @@ -1,18 +1,19 @@ -{ stdenv, callPackage }: +{callPackage, lib, stdenv}: let examples-shell = callPackage ./examples/shell.nix {}; examples-shell-with-emulator = callPackage ./examples/shell-with-emulator.nix {}; + all-tests = examples-shell.passthru.tests // + examples-shell-with-emulator.passthru.tests; in stdenv.mkDerivation { name = "androidenv-test-suite"; + buidInputs = lib.mapAttrsToList (name: value: value) all-tests; - src = ./.; + buildCommand = '' + touch $out + ''; - dontConfigure = true; - dontBuild = true; - - passthru.tests = examples-shell.passthru.tests // - examples-shell-with-emulator.passthru.tests; + passthru.tests = all-tests; meta.timeout = 60; }