Update build process
This commit is contained in:
@@ -15,6 +15,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
- name: Check runner arch
|
||||||
|
run: uname -m
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
run: nix develop --command gradle --no-daemon :app:test
|
run: nix develop --command gradle --no-daemon :app:test
|
||||||
- name: Build release APKs
|
- name: Build release APKs
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ Build toolchain: AGP 9.2.1, Gradle 9 (nixpkgs 26.05), build-tools 36, compileSdk
|
|||||||
This is a lab project (`lab` skill conventions apply) EXCEPT:
|
This is a lab project (`lab` skill conventions apply) EXCEPT:
|
||||||
|
|
||||||
- No container image, no helm chart, no /livez//readyz — artifact is an APK.
|
- No container image, no helm chart, no /livez//readyz — artifact is an APK.
|
||||||
- No `nix build`: gradle needs network for Maven deps. The flake is a dev
|
- No `nix build`: gradle needs network for Maven deps. Builds run via devshell
|
||||||
shell only. All builds run as `nix develop --command gradle ...`.
|
or `nix run` (see Commands below).
|
||||||
- Agents cannot run nix/gradle/adb here — ask the user to run commands
|
- Agents cannot run nix/gradle/adb here — ask the user to run commands
|
||||||
and report output.
|
and report output.
|
||||||
|
|
||||||
@@ -29,11 +29,13 @@ post-25.11). No file rewriting; `gradle.properties` stays untouched.
|
|||||||
|
|
||||||
## Commands (user-run, from repo root, direnv activates devshell)
|
## Commands (user-run, from repo root, direnv activates devshell)
|
||||||
|
|
||||||
- Tests: `gradle --no-daemon :app:test`
|
- Tests: `gradle --no-daemon :app:test`
|
||||||
- All APKs: `gradle --no-daemon :app:assembleRelease`
|
- All APKs: `gradle --no-daemon :app:assembleRelease`
|
||||||
→ `app/build/outputs/apk/<flavor>/release/<flavor>-release.apk`
|
→ `app/build/outputs/apk/<flavor>/release/<flavor>-release.apk`
|
||||||
- Single APK: `gradle --no-daemon :app:assembleWeatherRelease`
|
- Single APK: `gradle --no-daemon :app:assembleWeatherRelease`
|
||||||
- Deploy all: `tv-deploy` — connects, installs all flavor APKs, disconnects
|
- Build + deploy: `nix run` or `tv-deploy` (after manual build)
|
||||||
|
- Build only: `nix run .#build`
|
||||||
|
- Deploy only: `nix run .#deploy` or `tv-deploy` (in devshell)
|
||||||
(bump `versionCode` in app/build.gradle.kts first for upgrades)
|
(bump `versionCode` in app/build.gradle.kts first for upgrades)
|
||||||
- Fresh install: `adb connect $TV_IP:5555 && adb uninstall cz.c3c.webviewkiosk.<flavor> && adb install app/build/outputs/apk/<flavor>/release/<flavor>-release.apk`
|
- Fresh install: `adb connect $TV_IP:5555 && adb uninstall cz.c3c.webviewkiosk.<flavor> && adb install app/build/outputs/apk/<flavor>/release/<flavor>-release.apk`
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
# android-webview-kiosk — Android TV fullscreen WebView kiosk showing a
|
# android-webview-kiosk — Android TV fullscreen WebView kiosk showing a
|
||||||
# hardcoded Grafana dashboard, remote-launched via Sony Bravia IP control.
|
# hardcoded Grafana dashboard, remote-launched via Sony Bravia IP control.
|
||||||
#
|
#
|
||||||
# Deviation from lab Go template: this flake provides a DEV SHELL ONLY.
|
# Deviation from lab Go template: APK is built impurely (Gradle fetches Maven
|
||||||
# Gradle fetches Maven deps from the network, so the APK is built impurely:
|
# deps from the network). No `nix build` output; use nix run instead:
|
||||||
# nix develop --command gradle :app:assembleRelease
|
# nix run — build all APKs then deploy to TV
|
||||||
# There is no `nix build` output and no container/push pipeline.
|
# nix run .#build — build only
|
||||||
|
# nix run .#deploy — deploy already-built APKs to TV
|
||||||
description = "Android TV fullscreen WebView kiosk for the Grafana house dashboard";
|
description = "Android TV fullscreen WebView kiosk for the Grafana house dashboard";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
nixpkgs,
|
nixpkgs,
|
||||||
flake-utils,
|
flake-utils,
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
flake-utils.lib.eachSystem [ "x86_64-linux" ] (
|
||||||
system:
|
system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
@@ -44,16 +45,62 @@
|
|||||||
|
|
||||||
fonts = with pkgs; [ noto-fonts dejavu_fonts freefont_ttf ];
|
fonts = with pkgs; [ noto-fonts dejavu_fonts freefont_ttf ];
|
||||||
|
|
||||||
tvDeploy = pkgs.writeShellScriptBin "tv-deploy" ''
|
gradleEnv = {
|
||||||
set -euo pipefail
|
ANDROID_HOME = sdkRoot;
|
||||||
|
ANDROID_SDK_ROOT = sdkRoot;
|
||||||
|
JAVA_HOME = "${pkgs.jdk21}";
|
||||||
|
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${sdkRoot}/build-tools/${buildToolsVersion}/aapt2";
|
||||||
|
FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = fonts; };
|
||||||
|
};
|
||||||
|
|
||||||
|
deployScript = ''
|
||||||
trap 'adb disconnect "$TV_IP:5555"' EXIT
|
trap 'adb disconnect "$TV_IP:5555"' EXIT
|
||||||
adb connect "$TV_IP:5555"
|
adb connect "$TV_IP:5555"
|
||||||
for apk in app/build/outputs/apk/*/release/*.apk; do
|
for apk in app/build/outputs/apk/*/release/*.apk; do
|
||||||
adb install -r "$apk"
|
adb install -r "$apk"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
exportGradleEnv = ''
|
||||||
|
export ANDROID_HOME="${sdkRoot}"
|
||||||
|
export ANDROID_SDK_ROOT="${sdkRoot}"
|
||||||
|
export JAVA_HOME="${pkgs.jdk21}"
|
||||||
|
export GRADLE_OPTS="${gradleEnv.GRADLE_OPTS}"
|
||||||
|
export FONTCONFIG_FILE="${gradleEnv.FONTCONFIG_FILE}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
tvDeploy = pkgs.writeShellApplication {
|
||||||
|
name = "tv-deploy";
|
||||||
|
runtimeInputs = [ pkgs.android-tools ];
|
||||||
|
text = deployScript;
|
||||||
|
};
|
||||||
|
|
||||||
|
buildApp = pkgs.writeShellApplication {
|
||||||
|
name = "build";
|
||||||
|
runtimeInputs = [ androidSdk pkgs.jdk21 pkgs.gradle_9 ];
|
||||||
|
text = ''
|
||||||
|
${exportGradleEnv}
|
||||||
|
gradle --no-daemon :app:assembleRelease
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
buildAndDeploy = pkgs.writeShellApplication {
|
||||||
|
name = "build-and-deploy";
|
||||||
|
runtimeInputs = [ androidSdk pkgs.jdk21 pkgs.gradle_9 pkgs.android-tools ];
|
||||||
|
text = ''
|
||||||
|
${exportGradleEnv}
|
||||||
|
gradle --no-daemon :app:assembleRelease
|
||||||
|
${deployScript}
|
||||||
|
'';
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
apps = {
|
||||||
|
default = { type = "app"; program = "${buildAndDeploy}/bin/build-and-deploy"; };
|
||||||
|
build = { type = "app"; program = "${buildApp}/bin/build"; };
|
||||||
|
deploy = { type = "app"; program = "${tvDeploy}/bin/tv-deploy"; };
|
||||||
|
};
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = [
|
packages = [
|
||||||
androidSdk
|
androidSdk
|
||||||
@@ -64,15 +111,7 @@
|
|||||||
tvDeploy
|
tvDeploy
|
||||||
] ++ fonts;
|
] ++ fonts;
|
||||||
|
|
||||||
ANDROID_HOME = sdkRoot;
|
inherit (gradleEnv) ANDROID_HOME ANDROID_SDK_ROOT JAVA_HOME GRADLE_OPTS FONTCONFIG_FILE;
|
||||||
ANDROID_SDK_ROOT = sdkRoot;
|
|
||||||
JAVA_HOME = "${pkgs.jdk21}";
|
|
||||||
# NixOS gotcha: AGP downloads a dynamically-linked aapt2 from Maven
|
|
||||||
# that can't run on NixOS. Set android.aapt2FromMavenOverride via
|
|
||||||
# GRADLE_OPTS so AGP uses the SDK's aapt2 instead. Works since
|
|
||||||
# nixpkgs PR #449037 (merged post-25.11, present in 26.05+).
|
|
||||||
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${sdkRoot}/build-tools/${buildToolsVersion}/aapt2";
|
|
||||||
FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = fonts; };
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user