/flutter-nix

Simple Nix Flutter Environment

Primary LanguageNixMIT LicenseMIT

flutter-env-nix

A very simple flutter environment using packages provided by nix package manager.

pre-requisites

usage

tldr

clone repo, update variables in optionsFlutterCreate.nix and push to your own git repo

detailed

  • clone repository
    • git clone https://github.com/gesker/flutter-env-nix
  • delete .git folder
    • rm -rf flutter-env-nix/.git
  • cd into folder
    • cd flutter-env-nix
  • Update variables in optionsFlutterCreate.nix
    • values in optionsFlutterCreate.nix are used in execution of flutter create command
    • Note: The default folder specified for the flutter project myproject is already in .gitignore
    • The value of flutterProjectFolder in optionsFlutterCreate.nix can be an actual new sub-folder where your flutter project will be created OR it can be .
      • If set to . I would recommend renaming the folder flutter-env-nix to the name of your project
  • Take a good look at the following 2 files
    • flake.nix
      • Composes Android environment in similar fashion as described at wiki.nixos.org
      • Downloads and installed required software packaged from the NixOS repository
      • Sets MOST environment variables
        • ANDROID_NDK_ROOT
        • ANDROID_SDK_ROOT
        • CHROME_EXECUTABLE
        • CMAKE_ROOT
        • DART_ROOT
        • FLUTTER_ROOT
        • GRADLE_HOME
          • Default is .gradle in THIS directory
        • GRADLE_OPTS
        • JAVA_HOME
        • LANG
        • LC_ALL
        • PUB_CACHE
          • Default is .pub-cache in THIS directory
    • .envrc
      • These commands will be run by the direnv utility
      • Mostly output of ALL environment variables set in this project and the output of the flutter doctor command
      • Sets REMAINING environment variables
        • ANDROID_USER_HOME
        • ANDROID_AVD_HOME
        • PATH
    • run direnv allow
    • run git init, git remote add origin ..., git push, etc.

to-do (possibly)

  • decide if Android/Sdk needs to be linked to $HOME/Android/Sdk
    • So far this does not seem to be necessary
  • build Android and Android Studio based on values in flake.nix
    • Copy routines from NixOS repo ??
    • Currently just using the most recent versions Android tools provided by NixOS
  • fastlane template and github actions ??
  • verify emulator on MacOS

tips/hints

  • Android Studio is NOT installed on MacOS
  • Project can still be accessed from outside the project
  • Consider adding plugins to Android Studio that work with direnv