{ description = "Global — KDE Connect–compatible companion (Gleam domain + Android UI)"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # Theme crate (own repo). Local override: # nix run .#global --override-input vidya path:$HOME/code/vidya # Use the knot HTTPS URL (public, no SSH key). tangled.org AppView HTTPS often 404s. vidya = { url = "git+https://knot1.tangled.sh/nandi.uk/vidya"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, vidya, }: let systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forAllSystems = nixpkgs.lib.genAttrs systems; in { packages = forAllSystems ( system: { # Re-export the vidya flake package vidya = vidya.packages.${system}.default; default = vidya.packages.${system}.default; } ); apps = forAllSystems ( system: let pkgs = nixpkgs.legacyPackages.${system}; # Device launcher: build APK → adb install → Gleam dist_driver. # Bake flake-input path so cargo can path-depend on vidya without vendoring in git. global-run = (pkgs.writeShellApplication { name = "global"; runtimeInputs = [ pkgs.gleam pkgs.beamPackages.erlang pkgs.rebar3 pkgs.beamPackages.hex pkgs.cacert pkgs.python3 pkgs.git pkgs.android-tools pkgs.gnugrep pkgs.gawk pkgs.coreutils pkgs.procps pkgs.bash pkgs.cargo pkgs.rustc ]; text = '' set -euo pipefail export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" export NIX_SSL_CERT_FILE="$SSL_CERT_FILE" # Flake-locked vidya sources for cargo path dep (dist-ui → ../.flake/vidya) export GLOBAL_VIDYA_SRC="${vidya}" ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)" if [ -z "$ROOT" ]; then ROOT="$(pwd)" fi export GLOBAL_ROOT="$ROOT" exec bash "${./scripts/global-run.sh}" "$@" ''; }).overrideAttrs (_: { preferLocalBuild = true; allowSubstitutes = false; }); in { default = { type = "app"; program = "${global-run}/bin/global"; }; global = { type = "app"; program = "${global-run}/bin/global"; }; } ); devShells = forAllSystems ( system: let pkgs = nixpkgs.legacyPackages.${system}; in { default = pkgs.mkShell { name = "global"; packages = [ pkgs.gleam pkgs.beamPackages.erlang pkgs.rebar3 pkgs.beamPackages.hex pkgs.git pkgs.cacert pkgs.android-tools pkgs.just # Do NOT add pkgs.cargo / pkgs.rustc here: nixpkgs rustc has no # x86_64-linux-android std, and shadowing rustup breaks `just waydroid`. # Use host rustup (rustc + `rustup target add x86_64-linux-android`). ]; shellHook = '' export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" export NIX_SSL_CERT_FILE="$SSL_CERT_FILE" export GLOBAL_VIDYA_SRC="${vidya}" # Stage path dep for ad-hoc cargo builds, preferring a local checkout. if [ -d dist-ui ]; then mkdir -p .flake if [ -d "$HOME/code/vidya" ] && [ -f "$HOME/code/vidya/Cargo.toml" ]; then rm -rf .flake/vidya ln -sfn "$HOME/code/vidya" .flake/vidya elif [ ! -e .flake/vidya ]; then cp -aL "$GLOBAL_VIDYA_SRC" .flake/vidya chmod -R u+w .flake/vidya fi fi echo "global — device companion (vidya at .flake/vidya)" echo " just waydroid # APK → Waydroid (needs rustup + android target)" echo " nix run .#global # APK → install → Gleam" echo " gleam test" if ! command -v rustc >/dev/null 2>&1; then echo " warn: no rustc on PATH — install rustup and: rustup target add x86_64-linux-android" elif [ ! -d "$(rustc --print sysroot)/lib/rustlib/x86_64-linux-android/lib" ]; then echo " warn: active rustc lacks x86_64-linux-android — run: rustup target add x86_64-linux-android" echo " (and ensure which rustc points at ~/.rustup, not nixpkgs)" fi ''; }; } ); formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-rfc-style); }; }