Files
Greg Shuflin 00810ebfe6
Build Debug APK / build (push) Failing after 1m46s
Fix flake: include .txt data files and assets/ for GUI build
2026-04-14 16:03:35 -07:00

171 lines
5.3 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
description = "Synchronicity personal server runtime";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
rust-overlay,
crane,
flake-utils,
}: let
rust-version = "1.92.0";
in
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
overlays = [rust-overlay.overlays.default];
};
androidComposition = pkgs.androidenv.composeAndroidPackages {
platformVersions = ["35"];
buildToolsVersions = ["35.0.0" "36.0.0"];
ndkVersions = ["28.0.13004108"];
includeNDK = true;
includeSystemImages = false;
includeEmulator = false;
};
androidSdk = androidComposition.androidsdk;
rustToolchain = pkgs.rust-bin.stable."${rust-version}".default.override {
targets = ["aarch64-linux-android"];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
# Source filtering — include Cargo sources, .slint UI files, and
# data files referenced by include_str!() / include_bytes!()
rustSrc = pkgs.lib.cleanSourceWith {
src = ./rust;
filter = path: type:
(craneLib.filterCargoSources path type)
|| (builtins.match ".*\\.slint$" path != null)
|| (builtins.match ".*\\.txt$" path != null);
};
# Common arguments shared across all builds
commonArgs = {
src = rustSrc;
pname = "synchronicity";
version = "0.1.0";
strictDeps = true;
nativeBuildInputs = [
pkgs.pkg-config
];
buildInputs = [
pkgs.openssl
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.wayland
pkgs.libxkbcommon
pkgs.fontconfig
];
};
# Build workspace deps once (shared across all binaries)
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Helper to build a single binary from the workspace
mkBin = name: extraArgs: craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
cargoExtraArgs = "--bin ${name}";
# Only install the specific binary
doInstallCargoArtifacts = false;
} // extraArgs);
syn-cli = mkBin "syn-cli" {};
syn-tui = mkBin "syn-tui" {};
syn-gui = mkBin "syn-gui" {
buildInputs = commonArgs.buildInputs ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.libX11
pkgs.libxcursor
pkgs.libxrandr
pkgs.libxi
pkgs.libGL
];
# Slint UI files reference ../../../assets/ (relative to gui-app/ui/).
# Place the repo's assets/ dir where that relative path resolves.
preBuild = ''
mkdir -p ../assets
cp -r ${./assets}/* ../assets/
'';
# Slint needs to find wayland/X11 libs at runtime
postFixup = pkgs.lib.optionalString pkgs.stdenv.isLinux ''
patchelf --add-rpath ${pkgs.lib.makeLibraryPath [
pkgs.wayland
pkgs.libxkbcommon
pkgs.libGL
pkgs.libX11
pkgs.libxcursor
pkgs.libxrandr
pkgs.libxi
pkgs.fontconfig
]} $out/bin/syn-gui
'';
};
# CI scripts — source lives in scripts/ for proper shell highlighting
createReleaseCi = pkgs.writeShellScriptBin "create-release-ci" ''
export TEA_BIN="${pkgs.tea}/bin/tea"
exec bash ${./scripts/create-release-ci.sh} "$@"
'';
buildApkCi = pkgs.writeShellScriptBin "build-apk-ci" ''
export SCCACHE_BIN="${pkgs.sccache}/bin/sccache"
export CARGO_SWEEP_BIN="${pkgs.cargo-sweep}/bin/cargo-sweep"
export ANDROID_SDK_DIR="${androidSdk}/libexec/android-sdk"
export AAPT2_PATH="${androidSdk}/libexec/android-sdk/build-tools/35.0.0/aapt2"
exec bash ${./scripts/build-apk-ci.sh} "$@"
'';
in {
packages = {
inherit syn-cli syn-tui syn-gui;
default = syn-cli;
};
devShells.default = pkgs.mkShell {
buildInputs = [
buildApkCi
createReleaseCi
rustToolchain
pkgs.cargo-nextest
pkgs.typeshare
androidSdk
pkgs.jdk17
pkgs.just
];
ANDROID_HOME = "${androidSdk}/libexec/android-sdk";
ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
NDK_HOME = "${androidSdk}/libexec/android-sdk/ndk/28.0.13004108";
JAVA_HOME = "${pkgs.jdk17}";
shellHook = ''
cat > android/local.properties <<EOF
sdk.dir=${androidSdk}/libexec/android-sdk
android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/35.0.0/aapt2
EOF
'';
};
}
);
}