diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 176ae190a339..02188335129a 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -4,8 +4,8 @@ let getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; - flutterDrv = { version, pname, dartVersion, hash, dartHash }: mkFlutter { - inherit version pname; + flutterDrv = { version, pname, dartVersion, hash, dartHash, patches }: mkFlutter { + inherit version pname patches; dart = dart.override { version = dartVersion; sources = { @@ -17,9 +17,8 @@ let }; src = fetchurl { url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${version}-stable.tar.xz"; - sha256 = "sha256-MTZeWQUp4/TcPzYIT6eqIKSPUPvn2Mp/thOQzNgpTXg="; + sha256 = hash; }; - patches = getPatches ./patches; }; in { @@ -30,5 +29,15 @@ in dartVersion = "2.18.2"; hash = "sha256-MTZeWQUp4/TcPzYIT6eqIKSPUPvn2Mp/thOQzNgpTXg="; dartHash = "sha256-C3+YjecXLvSmJrLwi9H7TgD9Np0AArRWx3EdBrfQpTU"; + patches = getPatches ./patches/flutter3; + }; + + v2 = flutterDrv { + pname = "flutter"; + version = "2.10.5"; + dartVersion = "2.16.2"; + hash = "sha256-DTZwxlMUYk8NS1SaWUJolXjD+JnRW73Ps5CdRHDGnt0="; + dartHash = "sha256-egrYd7B4XhkBiHPIFE2zopxKtQ58GqlogAKA/UeiXnI="; + patches = getPatches ./patches/flutter2; }; } diff --git a/pkgs/development/compilers/flutter/patches/flutter2/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/flutter2/disable-auto-update.patch new file mode 100644 index 000000000000..e799f6e1550b --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/flutter2/disable-auto-update.patch @@ -0,0 +1,36 @@ +diff --git a/bin/internal/shared.sh b/bin/internal/shared.sh +index 05cba4393b..2a775bf24f 100644 +--- a/bin/internal/shared.sh ++++ b/bin/internal/shared.sh +@@ -217,8 +217,6 @@ function shared::execute() { + # FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS" + # FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432" + +- upgrade_flutter 7< "$PROG_NAME" +- + BIN_NAME="$(basename "$PROG_NAME")" + case "$BIN_NAME" in + flutter*) +diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +index 396756808e..d324a6df59 100644 +--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart ++++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +@@ -241,7 +241,6 @@ class FlutterCommandRunner extends CommandRunner { + globals.flutterUsage.suppressAnalytics = true; + } + +- globals.flutterVersion.ensureVersionFile(); + final bool machineFlag = topLevelResults['machine'] as bool? ?? false; + final bool ci = await globals.botDetector.isRunningOnBot; + final bool redirectedCompletion = !globals.stdio.hasTerminal && +@@ -250,10 +249,6 @@ class FlutterCommandRunner extends CommandRunner { + final bool versionCheckFlag = topLevelResults['version-check'] as bool? ?? false; + final bool explicitVersionCheckPassed = topLevelResults.wasParsed('version-check') && versionCheckFlag; + +- if (topLevelResults.command?.name != 'upgrade' && +- (explicitVersionCheckPassed || (versionCheckFlag && !isMachine))) { +- await globals.flutterVersion.checkFlutterVersionFreshness(); +- } + + // See if the user specified a specific device. + globals.deviceManager?.specifiedDeviceId = topLevelResults['device-id'] as String?; diff --git a/pkgs/development/compilers/flutter/patches/flutter2/git-dir.patch b/pkgs/development/compilers/flutter/patches/flutter2/git-dir.patch new file mode 100644 index 000000000000..0136ef93106d --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/flutter2/git-dir.patch @@ -0,0 +1,80 @@ +diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart +index 468a91a954..5def6897ce 100644 +--- a/dev/bots/prepare_package.dart ++++ b/dev/bots/prepare_package.dart +@@ -525,7 +525,7 @@ class ArchiveCreator { + + Future _runGit(List args, {Directory? workingDirectory}) { + return _processRunner.runProcess( +- ['git', ...args], ++ ['git', '--git-dir', '.git', ...args], + workingDirectory: workingDirectory ?? flutterRoot, + ); + } +diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart +index f2068a6ca2..99b161689e 100644 +--- a/packages/flutter_tools/lib/src/version.dart ++++ b/packages/flutter_tools/lib/src/version.dart +@@ -106,7 +106,7 @@ class FlutterVersion { + String? channel = _channel; + if (channel == null) { + final String gitChannel = _runGit( +- 'git rev-parse --abbrev-ref --symbolic @{u}', ++ 'git --git-dir .git rev-parse --abbrev-ref --symbolic @{u}', + globals.processUtils, + _workingDirectory, + ); +@@ -114,7 +114,7 @@ class FlutterVersion { + if (slash != -1) { + final String remote = gitChannel.substring(0, slash); + _repositoryUrl = _runGit( +- 'git ls-remote --get-url $remote', ++ 'git --git-dir .git ls-remote --get-url $remote', + globals.processUtils, + _workingDirectory, + ); +@@ -326,7 +326,7 @@ class FlutterVersion { + /// the branch name will be returned as `'[user-branch]'`. + String getBranchName({ bool redactUnknownBranches = false }) { + _branch ??= () { +- final String branch = _runGit('git rev-parse --abbrev-ref HEAD', globals.processUtils); ++ final String branch = _runGit('git --git-dir .git rev-parse --abbrev-ref HEAD', globals.processUtils); + return branch == 'HEAD' ? channel : branch; + }(); + if (redactUnknownBranches || _branch!.isEmpty) { +@@ -359,7 +359,7 @@ class FlutterVersion { + /// wrapper that does that. + @visibleForTesting + static List gitLog(List args) { +- return ['git', '-c', 'log.showSignature=false', 'log'] + args; ++ return ['git', '-c', 'log.showSignature=false', '--git-dir', '.git', 'log'] + args; + } + + /// Gets the release date of the latest available Flutter version. +@@ -730,7 +730,7 @@ class GitTagVersion { + + static GitTagVersion determine(ProcessUtils processUtils, {String? workingDirectory, bool fetchTags = false, String gitRef = 'HEAD'}) { + if (fetchTags) { +- final String channel = _runGit('git rev-parse --abbrev-ref HEAD', processUtils, workingDirectory); ++ final String channel = _runGit('git --git-dir .git rev-parse --abbrev-ref HEAD', processUtils, workingDirectory); + if (channel == 'dev' || channel == 'beta' || channel == 'stable') { + globals.printTrace('Skipping request to fetchTags - on well known channel $channel.'); + } else { +@@ -739,7 +739,7 @@ class GitTagVersion { + } + // find all tags attached to the given [gitRef] + final List tags = _runGit( +- 'git tag --points-at $gitRef', processUtils, workingDirectory).trim().split('\n'); ++ 'git --git-dir .git tag --points-at $gitRef', processUtils, workingDirectory).trim().split('\n'); + + // Check first for a stable tag + final RegExp stableTagPattern = RegExp(r'^\d+\.\d+\.\d+$'); +@@ -760,7 +760,7 @@ class GitTagVersion { + // recent tag and number of commits past. + return parse( + _runGit( +- 'git describe --match *.*.* --long --tags $gitRef', ++ 'git --git-dir .git describe --match *.*.* --long --tags $gitRef', + processUtils, + workingDirectory, + ) diff --git a/pkgs/development/compilers/flutter/patches/flutter2/move-cache.patch b/pkgs/development/compilers/flutter/patches/flutter2/move-cache.patch new file mode 100644 index 000000000000..a81d2def242c --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/flutter2/move-cache.patch @@ -0,0 +1,72 @@ +diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart +index ed42baea29..12941f733a 100644 +--- a/packages/flutter_tools/lib/src/asset.dart ++++ b/packages/flutter_tools/lib/src/asset.dart +@@ -11,11 +11,11 @@ import 'base/file_system.dart'; + import 'base/logger.dart'; + import 'base/platform.dart'; + import 'build_info.dart'; +-import 'cache.dart'; + import 'convert.dart'; + import 'dart/package_map.dart'; + import 'devfs.dart'; + import 'flutter_manifest.dart'; ++import 'globals.dart' as globals; + import 'license_collector.dart'; + import 'project.dart'; + +@@ -504,7 +504,7 @@ class ManifestAssetBundle implements AssetBundle { + } + final Uri entryUri = _fileSystem.path.toUri(asset); + result.add(_Asset( +- baseDir: _fileSystem.path.join(Cache.flutterRoot!, 'bin', 'cache', 'artifacts', 'material_fonts'), ++ baseDir: _fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter', 'artifacts', 'material_fonts'), + relativeUri: Uri(path: entryUri.pathSegments.last), + entryUri: entryUri, + package: null, +diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart +index defc86cc20..7fdf14d112 100644 +--- a/packages/flutter_tools/lib/src/cache.dart ++++ b/packages/flutter_tools/lib/src/cache.dart +@@ -22,6 +22,7 @@ import 'base/user_messages.dart'; + import 'build_info.dart'; + import 'convert.dart'; + import 'features.dart'; ++import 'globals.dart' as globals; + + const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo) + const String kFlutterEngineEnvironmentVariableName = 'FLUTTER_ENGINE'; // should point to //engine/src/ (root of flutter/engine repo) +@@ -322,8 +323,13 @@ class Cache { + return; + } + assert(_lock == null); ++ final Directory dir = _fileSystem.directory(_fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter')); ++ if (!dir.existsSync()) { ++ dir.createSync(recursive: true); ++ globals.os.chmod(dir, '755'); ++ } + final File lockFile = +- _fileSystem.file(_fileSystem.path.join(flutterRoot!, 'bin', 'cache', 'lockfile')); ++ _fileSystem.file(_fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter', 'lockfile')); + try { + _lock = lockFile.openSync(mode: FileMode.write); + } on FileSystemException catch (e) { +@@ -382,8 +388,7 @@ class Cache { + + String get devToolsVersion { + if (_devToolsVersion == null) { +- const String devToolsDirPath = 'dart-sdk/bin/resources/devtools'; +- final Directory devToolsDir = getCacheDir(devToolsDirPath, shouldCreate: false); ++ final Directory devToolsDir = _fileSystem.directory(_fileSystem.path.join(flutterRoot!, 'bin/cache/dart-sdk/bin/resources/devtools')); + if (!devToolsDir.existsSync()) { + throw Exception('Could not find directory at ${devToolsDir.path}'); + } +@@ -536,7 +541,7 @@ class Cache { + if (_rootOverride != null) { + return _fileSystem.directory(_fileSystem.path.join(_rootOverride!.path, 'bin', 'cache')); + } else { +- return _fileSystem.directory(_fileSystem.path.join(flutterRoot!, 'bin', 'cache')); ++ return _fileSystem.directory(_fileSystem.path.join(globals.fsUtils.homeDirPath!, '.cache', 'flutter')); + } + } + diff --git a/pkgs/development/compilers/flutter/patches/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch similarity index 100% rename from pkgs/development/compilers/flutter/patches/disable-auto-update.patch rename to pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch diff --git a/pkgs/development/compilers/flutter/patches/git-dir.patch b/pkgs/development/compilers/flutter/patches/flutter3/git-dir.patch similarity index 100% rename from pkgs/development/compilers/flutter/patches/git-dir.patch rename to pkgs/development/compilers/flutter/patches/flutter3/git-dir.patch diff --git a/pkgs/development/compilers/flutter/patches/move-cache.patch b/pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch similarity index 100% rename from pkgs/development/compilers/flutter/patches/move-cache.patch rename to pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ce740f6db459..2c06b2c45163 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13200,6 +13200,7 @@ with pkgs; flutterPackages = recurseIntoAttrs (callPackage ../development/compilers/flutter { }); flutter = flutterPackages.stable; + flutter2 = flutterPackages.v2; fnm = callPackage ../development/tools/fnm { inherit (darwin.apple_sdk.frameworks) DiskArbitration Foundation Security;