{
  description = "Nix development shell for the ntfy Android app";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
    flake-utils.url = "github:numtide/flake-utils";
  };

  nixConfig = {
    extra-substituters = [
      "https://cache.centralcloud.com/default"
    ];
    extra-trusted-public-keys = [
      "default:ywfU21WX06iOn2Ec2lae1jYh4w8LO4IQkmp06vJzsk8="
    ];
  };

  outputs = {
    nixpkgs,
    flake-utils,
    ...
  }:
    flake-utils.lib.eachDefaultSystem (system: let
      pkgs = import nixpkgs {
        inherit system;
        config.android_sdk.accept_license = true;
        config.allowUnfree = true;
      };

      androidComposition = pkgs.androidenv.composeAndroidPackages {
        platformVersions = ["36"];
        buildToolsVersions = ["36.0.0"];
        cmdLineToolsVersion = "latest";
        includeEmulator = false;
        includeNDK = false;
        includeSources = false;
        includeSystemImages = false;
      };

      androidSdk = androidComposition.androidsdk;
    in {
      devShells.default = pkgs.mkShell {
        packages = [
          androidSdk
          pkgs.git
          pkgs.gradle
          pkgs.jdk21
        ];

        ANDROID_HOME = "${androidSdk}/libexec/android-sdk";
        ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
        JAVA_HOME = pkgs.jdk21.home;

        shellHook = ''
          export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin:$PATH"
          echo "ntfy Android development shell"
          echo "  java        : $(java -version 2>&1 | head -n 1)"
          echo "  ANDROID_HOME: $ANDROID_HOME"
          echo ""
          echo "Useful checks:"
          echo "  ./gradlew tasks"
          echo "  ./gradlew :app:assembleFdroidDebug"
        '';
      };
    });
}
