I am in the following situation:
I have a flake for flutter development.
It gets activated by direnv when I enter the project folder and performs the flutter setup.
After that, I run flutter create .
to initialize the project.
I am including the flake and direnv files here.
flake.nix
{
description = "Flutter 3.0.4";
inputs = {
nixpkgs.url = "github:nanashi0x74/nixpkgs/flutter-3-0-0";
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 = "30.0.3";
androidComposition = pkgs.androidenv.composeAndroidPackages {
buildToolsVersions = [ buildToolsVersion "28.0.3" ];
platformVersions = [ "31" "28" ];
abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
};
androidSdk = androidComposition.androidsdk;
in
{
devShell =
with pkgs; mkShell rec {
ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
buildInputs = [
flutter
androidSdk
jdk11
];
};
});
}
flake.lock
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1657540956,
"narHash": "sha256-ihGbOFWtAkENwxBE5kV/yWt2MncvW+BObLDsmxCLo/Q=",
"owner": "nanashi0x74",
"repo": "nixpkgs",
"rev": "043de04db8a6b0391b3fefaaade160514d866946",
"type": "github"
},
"original": {
"owner": "nanashi0x74",
"ref": "flutter-3-0-0",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
.envrc
use flake
Now, I am developing for Android and flutter run
works perfectly from the shell where direnv is active.
The only problem I have left is this one:
Visual Studio Code (codium to be precise) does not see my phone as connected: it says “No Device” in the status bar at the bottom.
I have installed both the official dart and flutter extensions (Dart-Code.dart-code
and Dart-Code.flutter
)
Running flutter doctor
from the terminal (where direnv is active) gives me the following output (i.e., it correctly identifies the Android device):
Output from `flutter doctor` in the terminal where direnv is active
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.4, on NixOS 22.11 (Raccoon) 5.18.15, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[✗] 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 (the doctor check crashed)
✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at
https://github.com/flutter/flutter/issues.
✗ ProcessException: Failed to find "pkg-config" in the search path.
Command: pkg-config
[!] Android Studio (not installed)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
! Doctor found issues in 4 categories.
Output from `flutter doctor -v` in the terminal where direnv is active
[ +119 ms] executing: uname -m
[ +74 ms] Exit code 0 from: uname -m
[ ] x86_64
[ +11 ms] executing: [/nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/] git -c log.showSignature=false --git-dir .git log -n 1
--pretty=format:%H
[ +31 ms] Exit code 0 from: git -c log.showSignature=false --git-dir .git log -n 1 --pretty=format:%H
[ ] 85684f9300908116a78138ea4c6036c35c9a1236
[ +1 ms] executing: [/nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/] git --git-dir .git tag --points-at
85684f9300908116a78138ea4c6036c35c9a1236
[ +33 ms] Exit code 0 from: git --git-dir .git tag --points-at 85684f9300908116a78138ea4c6036c35c9a1236
[ ] 3.0.4
[ +19 ms] executing: [/nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/] git --git-dir .git rev-parse --abbrev-ref --symbolic @{u}
[ +14 ms] Exit code 0 from: git --git-dir .git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [/nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/] git --git-dir .git ls-remote --get-url origin
[ +14 ms] Exit code 0 from: git --git-dir .git ls-remote --get-url origin
[ ] https://github.com/flutter/flutter.git
[ +122 ms] executing: [/nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/] git --git-dir .git rev-parse --abbrev-ref HEAD
[ +9 ms] Exit code 0 from: git --git-dir .git rev-parse --abbrev-ref HEAD
[ ] stable
[ +112 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +7 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +99 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +123 ms] executing: [/nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/] git --git-dir .git rev-parse --abbrev-ref HEAD
[ +8 ms] Exit code 0 from: git --git-dir .git rev-parse --abbrev-ref HEAD
[ ] stable
[ ] Skipping request to fetchTags - on well known channel stable.
[ ] executing: [/nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/] git --git-dir .git tag --points-at HEAD
[ +26 ms] Exit code 0 from: git --git-dir .git tag --points-at HEAD
[ ] 3.0.4
[ +83 ms] executing: [/nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/] git -c log.showSignature=false --git-dir .git log -n 1
--pretty=format:%ar
[ +17 ms] Exit code 0 from: git -c log.showSignature=false --git-dir .git log -n 1 --pretty=format:%ar
[ +1 ms] 5 weeks ago
[ +121 ms] executing: /nix/store/5sdq8zhi6cnf3wl6kjk4n3qrs6z9h1n7-androidsdk/libexec/android-sdk/platform-tools/adb devices -l
[ +77 ms] [✓] Flutter (Channel stable, 3.0.4, on NixOS 22.11 (Raccoon) 5.18.15, locale en_US.UTF-8)
[ +1 ms] • Flutter version 3.0.4 at /nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped
[ ] • Upstream repository https://github.com/flutter/flutter.git
[ ] • Framework revision 85684f9300 (5 weeks ago), 2022-06-30 13:22:47 -0700
[ ] • Engine revision 6ba2af10bb
[ ] • Dart version 2.17.5
[ ] • DevTools version 2.12.2
[ +98 ms] List of devices attached
41425U8901U99526 device usb:1-1 product:SM-A505W model:SM_A505W device:SMA505W transport_id:1
[ +11 ms] /nix/store/5sdq8zhi6cnf3wl6kjk4n3qrs6z9h1n7-androidsdk/libexec/android-sdk/platform-tools/adb -s 41425U8901U99526 shell getprop
[ +185 ms] ro.hardware = hi6250
[ ] ro.build.characteristics = default
[ +9 ms] executing: /nix/store/5sdq8zhi6cnf3wl6kjk4n3qrs6z9h1n7-androidsdk/libexec/android-sdk/platform-tools/adb devices -l
[ +25 ms] List of devices attached
41425U8901U99526 device usb:1-1 product:SM-A505W model:SM_A505W device:SMA505W transport_id:1
[ +62 ms] [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[ ] • Android SDK at /nix/store/5sdq8zhi6cnf3wl6kjk4n3qrs6z9h1n7-androidsdk/libexec/android-sdk
[ +1 ms] ✗ cmdline-tools component is missing
[ ] Run `path/to/sdkmanager --install "cmdline-tools;latest"`
[ ] See https://developer.android.com/studio/command-line for more details.
[ ] ✗ Android license status unknown.
[ ] Run `flutter doctor --android-licenses` to accept the SDK licenses.
[ ] See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[ +4 ms] [✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
[ ] ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[ +1 ms] [☠] Linux toolchain - develop for Linux desktop (the doctor check crashed)
[ +2 ms] ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at
https://github.com/flutter/flutter/issues.
[ ] ✗ ProcessException: Failed to find "pkg-config" in the search path.
[ ] Command: pkg-config
[ ] • #0 LocalProcessManager.run (package:process/src/interface/local_process_manager.dart:87:7)
[ ] #1 ErrorHandlingProcessManager.run. (package:flutter_tools/src/base/error_handling_io.dart:669:24)
[ ] #2 _run (package:flutter_tools/src/base/error_handling_io.dart:567:20)
[ ] #3 ErrorHandlingProcessManager.run (package:flutter_tools/src/base/error_handling_io.dart:668:12)
[ ] #4 LinuxDoctorValidator._libraryIsPresent (package:flutter_tools/src/linux/linux_doctor.dart:186:38)
[ ] #5 LinuxDoctorValidator.validate (package:flutter_tools/src/linux/linux_doctor.dart:145:20)
[ ]
[ ] #6 Future.any.onValue (dart:async/future.dart:611:5)
[ ]
[ +1 ms] [!] Android Studio (not installed)
[ ] • Android Studio not found; download from https://developer.android.com/studio/index.html
[ ] (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
[ +4 ms] [✓] Connected device (2 available)
[ ] • SM A505W (mobile) • 41425U8901U99526 • android-arm64 • Android 9 (API 28)
[ ] • Linux (desktop) • linux • linux-x64 • NixOS 22.11 (Raccoon) 5.18.15
[+1028 ms] [✓] HTTP Host Availability
[ ] • All required HTTP hosts are available
[ ] ! Doctor found issues in 4 categories.
[ +19 ms] "flutter doctor" took 2,076ms.
[ +50 ms] ensureAnalyticsSent: 43ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 0
Flutter daemon log (obtained by setting the dart.flutterDaemonLogFile option
!! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!
Dart Code extension: 3.44.0
Flutter extension: 3.44.0 (not activated)
App: VSCodium
Version: 1.69.2
Platform: linux
HTTP_PROXY: undefined
NO_PROXY: undefined
Logging Categories:
FlutterDaemon
Thu Aug 04 2022 [09:37:48 GMT+0200 (Central European Summer Time)] Log file started
[9:37:48 AM] [FlutterDaemon] [Info] Spawning /nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped/bin/flutter with args [“daemon”]
[9:37:48 AM] [FlutterDaemon] [Info] … in /nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped
[9:37:48 AM] [FlutterDaemon] [Info] … with {“toolEnv”:{“FLUTTER_HOST”:“VSCode”,“PUB_ENVIRONMENT”:“vscode.dart-code”}}
[9:37:48 AM] [FlutterDaemon] [Info] PID: 31555
[9:37:48 AM] [FlutterDaemon] [Info] ==> [{“id”:“1”,“method”:“emulator.getEmulators”}]
[9:37:50 AM] [FlutterDaemon] [Info] <== [{“event”:“daemon.connected”,“params”:{“version”:“0.6.1”,“pid”:31722}}]
[9:37:50 AM] [FlutterDaemon] [Info] ==> [{“id”:“2”,“method”:“device.enable”}]
[9:37:50 AM] [FlutterDaemon] [Info] <== [{“event”:“daemon.logMessage”,“params”:{“level”:“status”,“message”:“Starting device daemon…”}}]
[9:37:50 AM] [FlutterDaemon] [Info] <== [{“id”:“1”,“result”:}]
[9:37:50 AM] [FlutterDaemon] [Info] <== [{“id”:“2”}]
[9:37:54 AM] [FlutterDaemon] [Info] <== [{“event”:“device.added”,“params”:{“id”:“linux”,“name”:“Linux”,“platform”:“linux-x64”,“emulator”:false,“category”:“desktop”,“platformType”:“linux”,“ephemeral”:false,“emulatorId”:null,“sdk”:“NixOS 22.11 (Raccoon) 5.18.15”,“capabilities”:{“hotReload”:true,“hotRestart”:true,“screenshot”:false,“fastStart”:false,“flutterExit”:true,“hardwareRendering”:true,“startPaused”:true}}}]
[9:37:54 AM] [FlutterDaemon] [Info] ==> [{“id”:“3”,“method”:“daemon.getSupportedPlatforms”,“params”:{“projectRoot”:“/home/racoon/Projects/Flutter/Test1”}}]
[9:37:54 AM] [FlutterDaemon] [Info] <== [{“id”:“3”,“result”:{“platforms”:[“android”]}}]
While running flutter doctor through vs code’s command palette (ctrl+shift+p
) does not see the Android device (sees only linux).
output from `Flutter: run flutter doctor` in vscode
[flutter] flutter doctor -v
[!] Flutter (Channel stable, 3.0.4, on NixOS 22.11 (Raccoon) 5.18.15, locale en_US.UTF-8)
• Flutter version 3.0.4 at /nix/store/gi3sf2xn0mshk5qsrrsdkdd51q0d47xv-flutter-3.0.4-unwrapped
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 85684f9300 (5 weeks ago), 2022-06-30 13:22:47 -0700
• Engine revision 6ba2af10bb
• Dart version 2.17.5
• DevTools version 2.12.2
✗ Downloaded executables cannot execute on host.
See https://github.com/flutter/flutter/issues/6207 for more information
On Debian/Ubuntu/Mint: sudo apt-get install lib32stdc++6
On Fedora: dnf install libstdc++.i686
On Arch: pacman -S lib32-gcc-libs
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: Download Android Studio & App Tools - Android Developers
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
flutter config --android-sdk
to update to that location.
[✗] 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 (the doctor check crashed)
✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at Issues · flutter/flutter · GitHub.
✗ ProcessException: Failed to find “pkg-config” in the search path.
Command: pkg-config
• #0 LocalProcessManager.run (package:process/src/interface/local_process_manager.dart:87:7)
#1 ErrorHandlingProcessManager.run. (package:flutter_tools/src/base/error_handling_io.dart:669:24)
#2 _run (package:flutter_tools/src/base/error_handling_io.dart:567:20)
#3 ErrorHandlingProcessManager.run (package:flutter_tools/src/base/error_handling_io.dart:668:12)
#4 LinuxDoctorValidator._libraryIsPresent (package:flutter_tools/src/linux/linux_doctor.dart:186:38)
#5 LinuxDoctorValidator.validate (package:flutter_tools/src/linux/linux_doctor.dart:145:20)
#6 Future.any.onValue (dart:async/future.dart:611:5)
[!] Android Studio (not installed)
• Android Studio not found; download from Download Android Studio & App Tools - Android Developers
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
[✓] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • NixOS 22.11 (Raccoon) 5.18.15
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 5 categories.
exit code 0
I have adb enabled in my system-wide NixOS config with:
programs.adb.enable = true;
users.users.${config.username}.extraGroups = [ "adbusers" ];
Has anyone else experienced a similar problem or knows how to fix this?
I tried the workaround suggested here, but with no luck.
Looking at the outputs, I guess it may be because somehow vscode does not run the command adb devices -l
, which does indeed list only my Android device.