I copied the first flake.nix from https://nixos.wiki/wiki/Flutter, and everything works fine when I run nix develop
But I need to switch to the beta channel, so when I run flutter channel beta
I get the error
Switching to flutter channel ‘beta’…
Switching channels failed
fatal: detected dubious ownership in repository at
‘/nix/store/nir2w2fd8xj3i45gmqbbqbcm4kivf1j4-flutter-wrapped-3.27.1-sdk-links’
To add an exception for this directory, call:
git config --global --add safe.directory
/nix/store/nir2w2fd8xj3i45gmqbbqbcm4kivf1j4-flutter-wrapped-3.27.1-sdk-links.
Running git config --global --add safe.directory /nix/store/nir2w2fd8xj3i45gmqbbqbcm4kivf1j4-flutter-wrapped-3.27.1-sdk-links
and then flutter run upgrade again, I get the error
Switching to flutter channel ‘beta’…
Switching channels failed
error: cannot open ‘.git/FETCH_HEAD’: Read-only file system.
I see flutterPackages-source.beta exists in the nixpkgs, but I’m not sure how to use it.
Any help for upgrading to the flutter beta channel would be appreciated.
Here is my flake.nix
{
description = "Flutter 3.27.x";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
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 = "34.0.0";
androidComposition = pkgs.androidenv.composeAndroidPackages {
buildToolsVersions = [ buildToolsVersion "28.0.3" ];
platformVersions = [ "34" "28" ];
abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
};
androidSdk = androidComposition.androidsdk;
in
{
devShell =
with pkgs; mkShell {
ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
buildInputs = [
flutter
flutterPackages-source.beta
androidSdk # The customized SDK that we've made above
jdk17
];
shellHook = ''
zsh
'';
};
});
}
I get the same git error when I use buildFSHEnv
{
description = "Flutter 3.27.x";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
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 = "34.0.0";
androidComposition = pkgs.androidenv.composeAndroidPackages {
buildToolsVersions = [ buildToolsVersion "28.0.3" ];
platformVersions = [ "34" "28" ];
abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
};
androidSdk = androidComposition.androidsdk;
in
{
devShell =
(pkgs.buildFHSEnv {
name = "flutter beta";
targetPkgs = pkgs:
[ pkgs.flutter androidSdk pkgs.jdk17 ];
runScript = ''
zsh
export ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk";
'';
}).env;
});
}