{ description = "Nix flake to develop for Android"; nixConfig = { extra-substituters = [ #"https://haskell-miso-cachix.cachix.org" ]; extra-trusted-public-keys = [ #"haskell-miso-cachix.cachix.org-1:m8hN1cvFMJtYib4tj+06xkKt5ABMSGfe8W7s40x1kQ0=" ]; #allow-import-from-derivation = "true"; }; inputs = { nixpkgs.url = "flake:nixpkgs"; miso.url = "github:dmjio/miso"; miso.inputs.nixpkgs.follows = "nixpkgs"; miso-lynx.url = "github:dmjio/miso-lynx"; miso-lynx.flake = false; ghcjs-base.url = "github:ghcjs/ghcjs-base"; ghcjs-base.flake = false; # ExplanationNote: an alternative way to install Android tools, # not sure if it's better than nixpkgs' machinery at anything. # Just here for reference. android-nixpkgs = { url = "github:tadfisher/android-nixpkgs"; # ExplanationNote: # The main branch follows the "canary" channel of the Android SDK # repository. Use another android-nixpkgs branch to explicitly # track an SDK release channel. # # url = "github:tadfisher/android-nixpkgs/stable"; # url = "github:tadfisher/android-nixpkgs/beta"; # url = "github:tadfisher/android-nixpkgs/preview"; # url = "github:tadfisher/android-nixpkgs/canary"; # ExplanationNote: replace the "nixpkgs" input for the "android-nixpkgs" flake. inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = inputs: let systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; lib = inputs.nixpkgs.lib; perSystem = f: lib.genAttrs lib.systems.flakeExposed ( system: f rec { inherit system; #pkgs = inputs.nixpkgs.legacyPackages.${system}; pkgs = import inputs.nixpkgs { inherit system; config = { android_sdk.accept_license = true; allowUnfreePredicate = pkg: builtins.elem (pkgs.lib.getName pkg) [ "android-sdk-build-tools" "android-sdk-cmdline-tools" "android-sdk-ndk" "android-sdk-platform-tools" "android-sdk-platforms" "emulator" "android-sdk-tools" "android-studio-stable" "android-emulate-app" "build-tools" "cmake" "cmdline-tools" "ndk" "platform-tools" "platforms" "tools" "android-sdk-emulator" "android-sdk-system-image-${android.config.androidPlatformVersion}-google_apis_playstore-x86_64" "system-image-${android.config.androidPlatformVersion}-google_apis_playstore-x86_64" "system-image-${android.config.androidPlatformVersion}-google_apis-x86_64" "android-sdk-system-image-${android.config.androidPlatformVersion}-google_apis-x86_64" ]; }; overlays = [ (import nix/overlays/ghc.nix inputs) ]; }; android = pkgs.callPackage android/default.nix { inherit inputs system; mainLynxBundle = pkgs.callPackage src/default.nix { miso-lynx = inputs.miso-lynx; ghc = pkgs.pkgsCross.ghcjs.haskell.packages.ghc9122; #ghc = pkgs.pkgsCross.ghcjs.haskell.packages.ghcNative; }; }; } ); in { # nix -L build .#pkgsCross.ghcjs.haskell.packages.ghcNative.miso-lynx-examples packages = perSystem ( args: with args; { default = android.packages.default; android = android.packages.default; android-emulator-x86_64 = android.packages.android-emulator-x86_64; /* haskell = pkgs.haskell; pkgsCross = pkgs.pkgsCross; androidComposition = android.config.androidComposition; miso-ghc-9122 = inputs.miso.packages.${system}.miso-ghc-9122; miso-ghcjs-9122 = inputs.miso.packages.${system}.miso-ghcjs-9122; miso-ghcjs-9122-2 = pkgs.pkgsCross.ghcjs.haskell.packages.ghc9122.miso; miso-ghc-9122-2 = pkgs.pkgsCross.ghcjs.haskell.packages.ghcNative.miso; android-sdk = inputs.android-nixpkgs.sdk ( sdkPkgs: with sdkPkgs; [ cmdline-tools-latest build-tools-35-0-0 platform-tools platforms-android-36 emulator ] ); */ } ); devShells = perSystem ( args: with args; { default = pkgs.mkShell { buildInputs = android.devShells.default.buildInputs ++ [ pkgs.http-server #pkgs.emscripten ]; shellHook = '' ${android.devShells.default.shellHook} ''; }; } ); }; }