flake.nix
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config = {
android_sdk.accept_license = true;
allowUnfree = true;
};
};
buildToolsVersion = "33.0.2";
androidComposition = pkgs.androidenv.composeAndroidPackages
{
buildToolsVersions = [ buildToolsVersion ];
platformVersions = [ "31" "33" ];
abiVersions = [ "armeabi-v7a" "arm64-v8a" "x86_64" ];
includeSystemImages = true;
includeEmulator = true;
useGoogleAPIs = true;
};
androidSdk = androidComposition.androidsdk;
in
{
devShells.default =
with pkgs; mkShell {
ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
packages = [
bashInteractive
flutter
androidSdk
jdk11
];
};
});
}
.envrc
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi
use flake
flutter doctor by vscode extension
[flutter] flutter doctor -v
[✓] Flutter (Channel stable, 3.10.5, on NixOS 23.11 (Tapir) 6.4.7-zen1, locale en_US.UTF-8)
• Flutter version 3.10.5 on channel stable at /nix/store/d5phjwalnggcbab5qwbm6knfmghi6knf-flutter-3.10.5-unwrapped
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (8 周前), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /nix/store/czaracamshrsnd4jkkcics6q8z9m24zd-androidsdk/libexec/android-sdk
• Platform android-33, build-tools 33.0.2
• ANDROID_SDK_ROOT = /nix/store/czaracamshrsnd4jkkcics6q8z9m24zd-androidsdk/libexec/android-sdk
• Java binary at: /nix/store/59i7hzgwjpg4g7xy2wh9v78163g7x5zf-android-studio-stable-2022.3.1.18-unwrapped/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✗] Linux toolchain - develop for Linux desktop
✗ clang++ is required for Linux development.
It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
✗ CMake is required for Linux development.
It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/
✗ ninja is required for Linux development.
It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
✗ pkg-config is required for Linux development.
It is likely available from your distribution (e.g.: apt install pkg-config), or can be downloaded from https://www.freedesktop.org/wiki/Software/pkg-config/
[✓] Android Studio (version 2022.3)
• Android Studio at /nix/store/59i7hzgwjpg4g7xy2wh9v78163g7x5zf-android-studio-stable-2022.3.1.18-unwrapped
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
• IntelliJ at /nix/store/y2y48l37qi8sx8dsy10cf86flgli3n8z-idea-ultimate-2023.2/idea-ultimate
• Flutter plugin version 75.1.4
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • NixOS 23.11 (Tapir) 6.4.7-zen1
! Device emulator-5554 is offline.
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 3 categories.
exit code 0
flutter doctor -v in terminal
impure ~/C/news_app flutter doctor -v nix-shell-env
[✓] Flutter (Channel stable, 3.10.5, on NixOS 23.11 (Tapir) 6.4.7-zen1, locale en_US.UTF-8)
• Flutter version 3.10.5 on channel stable at /nix/store/d5phjwalnggcbab5qwbm6knfmghi6knf-flutter-3.10.5-unwrapped
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (8 周前), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /nix/store/czaracamshrsnd4jkkcics6q8z9m24zd-androidsdk/libexec/android-sdk
• Platform android-33, build-tools 33.0.2
• ANDROID_SDK_ROOT = /nix/store/czaracamshrsnd4jkkcics6q8z9m24zd-androidsdk/libexec/android-sdk
• Java binary at: /nix/store/wp16ly0sx6k064a0kjr6kp8m6mf58a20-openjdk-11.0.19+7/lib/openjdk/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.19+0-adhoc..source)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
• clang version 11.1.0
• cmake version 3.26.4
• ninja version 1.11.1
• pkg-config version 0.29.2
[!] Android Studio (version 2022.3)
• Android Studio at /nix/store/59i7hzgwjpg4g7xy2wh9v78163g7x5zf-android-studio-stable-2022.3.1.18-unwrapped
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Failed to run Java: ProcessException: No such file or directory
Command: /nix/store/59i7hzgwjpg4g7xy2wh9v78163g7x5zf-android-studio-stable-2022.3.1.18-unwrapped/jbr/bin/java -version
✗ Unable to determine bundled Java version.
• Try updating or re-installing Android Studio.
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2)
• IntelliJ at /nix/store/y2y48l37qi8sx8dsy10cf86flgli3n8z-idea-ultimate-2023.2/idea-ultimate
• Flutter plugin version 75.1.4
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • NixOS 23.11 (Tapir) 6.4.7-zen1
! Device emulator-5554 is offline.
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 3 categories.
vscode installed by home-manager
programs = {
vscode = {
enable = true;
package = pkgs.vscode.fhs;
};
};