Flutter: Difference between revisions

From NixOS Wiki
imported>ANicon111
No edit summary
imported>ANicon111
m Removed non-functioning build setups
Line 1: Line 1:
== Developement enviroment ==
== Developement enviroment ==


To be able to build flutter apps, you need to add the platform-specific dependencies to your environment. This may be done by running <code>nix-shell</code> using this shell.nix configuration:
To be able to build flutter apps, you need to add the platform-specific dependencies to your environment. This may be done by running <code>nix-shell</code> using a shell.nix configuration:


<syntaxhighlight lang=nix>
<syntaxhighlight lang=nix>
Line 9: Line 9:
in pkgs.mkShell {
in pkgs.mkShell {
   buildInputs = with pkgs; [
   buildInputs = with pkgs; [
     flutter
     flutter git
    #linux build
    cmake clang ninja pkg-config pkgconfig gtk3 libepoxy
     #android build
     #android build
     (android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [cmdline-tools-latest build-tools-32-0-0 platform-tools platforms-android-31 system-images-android-31-default-x86-64 emulator]))
     (android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [cmdline-tools-latest build-tools-32-0-0 platform-tools platforms-android-31 system-images-android-31-default-x86-64 emulator]))
     jdk unzip
     jdk8 unzip
    #web build
    chromium
   ];
   ];
  CHROME_EXECUTABLE = "${pkgs.chromium}";
}
}
</syntaxhighlight>
</syntaxhighlight>


This uses the tool android-nixpkgs made by tadfisher to get all the android dependencies (be sure to change the package versions/branch to your needs; they can be found here: https://github.com/tadfisher/android-nixpkgs/tree/main/channels )
This file uses the tool android-nixpkgs made by tadfisher to get all the android dependencies (be sure to change the package versions/branch to your needs; they can be found here: https://github.com/tadfisher/android-nixpkgs/tree/main/channels )
 
Also be sure to run <code>avdmanager create avd -n "Android" -k "system-images;android-31;default;x86_64"</code> to create an android emulator

Revision as of 12:43, 29 January 2023

Developement enviroment

To be able to build flutter apps, you need to add the platform-specific dependencies to your environment. This may be done by running nix-shell using a shell.nix configuration:

{ pkgs ? import <nixpkgs> {} }:
let android-nixpkgs = (pkgs.callPackage (import (builtins.fetchGit {url = "https://github.com/tadfisher/android-nixpkgs.git";})) {channel = "stable";});

in pkgs.mkShell {
  buildInputs = with pkgs; [
    flutter git
    #android build
    (android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [cmdline-tools-latest build-tools-32-0-0 platform-tools platforms-android-31 system-images-android-31-default-x86-64 emulator]))
    jdk8 unzip
  ];
}

This file uses the tool android-nixpkgs made by tadfisher to get all the android dependencies (be sure to change the package versions/branch to your needs; they can be found here: https://github.com/tadfisher/android-nixpkgs/tree/main/channels )

Also be sure to run avdmanager create avd -n "Android" -k "system-images;android-31;default;x86_64" to create an android emulator