From d037e64ef6c876083b3bf1dfa80c73517e18e746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20Rivi=C3=A8re?= Date: Tue, 24 Dec 2019 18:01:45 +0100 Subject: [PATCH 1/2] flutter: init 1.12.13+hotfix.8 flutter: add beta and dev channels flutter: artifacts are now downloaded in $HOME/.cache/flutter flutter: remove all artifacts from flutter flutter: fix lockfile path flutter: fix pub_cache flutter: fix flutter_tools/.packages pointing to /build flutter: clean patches flutter: fix write error on .cache/flutter/lockfile flutter: add zlib as a dependency flutter: add missing dependencies flutter: fix flutter version flutter: update versions + dependencies --- .../development/compilers/flutter/default.nix | 30 ++++ .../development/compilers/flutter/flutter.nix | 128 ++++++++++++++++++ .../patches/beta/disable-auto-update.patch | 31 +++++ .../flutter/patches/beta/move-cache.patch | 63 +++++++++ .../patches/dev/disable-auto-update.patch | 31 +++++ .../flutter/patches/dev/move-cache.patch | 63 +++++++++ .../patches/stable/disable-auto-update.patch | 31 +++++ .../flutter/patches/stable/move-cache.patch | 63 +++++++++ pkgs/top-level/all-packages.nix | 4 + 9 files changed, 444 insertions(+) create mode 100644 pkgs/development/compilers/flutter/default.nix create mode 100644 pkgs/development/compilers/flutter/flutter.nix create mode 100644 pkgs/development/compilers/flutter/patches/beta/disable-auto-update.patch create mode 100644 pkgs/development/compilers/flutter/patches/beta/move-cache.patch create mode 100644 pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch create mode 100644 pkgs/development/compilers/flutter/patches/dev/move-cache.patch create mode 100644 pkgs/development/compilers/flutter/patches/stable/disable-auto-update.patch create mode 100644 pkgs/development/compilers/flutter/patches/stable/move-cache.patch diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix new file mode 100644 index 00000000000..89e05be1e4e --- /dev/null +++ b/pkgs/development/compilers/flutter/default.nix @@ -0,0 +1,30 @@ +{ callPackage }: + +let + mkFlutter = opts: callPackage (import ./flutter.nix opts) { }; + getPatches = dir: + let files = builtins.attrNames (builtins.readDir dir); + in map (f: dir + ("/" + f)) files; +in { + stable = mkFlutter { + pname = "flutter"; + channel = "stable"; + version = "1.12.13+hotfix.8"; + sha256Hash = "01ik4xckr3fp65sq4g0g6wy5b9i0r49l643xmbxa6z9k21sby46d"; + patches = getPatches ./patches/stable; + }; + beta = mkFlutter { + pname = "flutter-beta"; + channel = "beta"; + version = "1.14.6"; + sha256Hash = "1a79pr741zkr39p5gc3p9x59d70vm60hpz2crgc53ysglj4ycigy"; + patches = getPatches ./patches/beta; + }; + dev = mkFlutter { + pname = "flutter-dev"; + channel = "dev"; + version = "1.15.3"; + sha256Hash = "06mawwqf7q7wdmzlyxlrlblhnnk4ckf3vp92lplippdh3d52r93i"; + patches = getPatches ./patches/dev; + }; +} diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix new file mode 100644 index 00000000000..1b9c482d6e9 --- /dev/null +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -0,0 +1,128 @@ +{ channel, pname, version, sha256Hash, patches }: + +{ bash, buildFHSUserEnv, cacert, coreutils, git, makeWrapper, runCommand, stdenv +, fetchurl, alsaLib, dbus, expat, libpulseaudio, libuuid, libX11, libxcb +, libXcomposite, libXcursor, libXdamage, libXfixes, libGL, nspr, nss, systemd }: + +let + drvName = "flutter-${channel}-${version}"; + flutter = stdenv.mkDerivation { + name = "${drvName}-unwrapped"; + + src = fetchurl { + url = + "https://storage.googleapis.com/flutter_infra/releases/${channel}/linux/flutter_linux_v${version}-${channel}.tar.xz"; + sha256 = sha256Hash; + }; + + buildInputs = [ makeWrapper git ]; + + inherit patches; + + postPatch = '' + patchShebangs --build ./bin/ + find ./bin/ -executable -type f -exec patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) {} \; + ''; + + buildPhase = '' + FLUTTER_ROOT=$(pwd) + FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools" + SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" + STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" + SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart" + DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk" + + DART="$DART_SDK_PATH/bin/dart" + PUB="$DART_SDK_PATH/bin/pub" + + HOME=../.. # required for pub upgrade --offline, ~/.pub-cache + # path is relative otherwise it's replaced by /build/flutter + + (cd "$FLUTTER_TOOLS_DIR" && "$PUB" upgrade --offline) + + local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" + "$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH" + echo "$revision" > "$STAMP_PATH" + echo -n "${version}" > version + + rm -rf bin/cache/{artifacts,downloads} + rm -f bin/cache/*.stamp + ''; + + installPhase = '' + mkdir -p $out + cp -r . $out + ''; + }; + + # Wrap flutter inside an fhs user env to allow execution of binary, + # like adb from $ANDROID_HOME or java from android-studio. + fhsEnv = buildFHSUserEnv { + name = "${drvName}-fhs-env"; + multiPkgs = pkgs: [ + # Flutter only use these certificates + (runCommand "fedoracert" { } '' + mkdir -p $out/etc/pki/tls/ + ln -s ${cacert}/etc/ssl/certs $out/etc/pki/tls/certs + '') + pkgs.zlib + ]; + targetPkgs = pkgs: + with pkgs; [ + bash + curl + git + unzip + which + xz + + # flutter test requires this lib + libGLU + + # for android emulator + alsaLib + dbus + expat + libpulseaudio + libuuid + libX11 + libxcb + libXcomposite + libXcursor + libXdamage + libXfixes + libGL + nspr + nss + systemd + ]; + }; + +in runCommand drvName { + startScript = '' + #!${bash}/bin/bash + export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} + export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 + ${fhsEnv}/bin/${drvName}-fhs-env ${flutter}/bin/flutter --no-version-check "$@" + ''; + preferLocalBuild = true; + allowSubstitutes = false; + passthru = { unwrapped = flutter; }; + meta = with stdenv.lib; { + description = + "Flutter is Google's SDK for building mobile, web and desktop with Dart."; + longDescription = '' + Flutter is Google’s UI toolkit for building beautiful, + natively compiled applications for mobile, web, and desktop from a single codebase. + ''; + homepage = "https://flutter.dev"; + license = licenses.bsd3; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ babariviere ]; + }; +} '' + mkdir -p $out/bin + + echo -n "$startScript" > $out/bin/${pname} + chmod +x $out/bin/${pname} +'' diff --git a/pkgs/development/compilers/flutter/patches/beta/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/beta/disable-auto-update.patch new file mode 100644 index 00000000000..42c09c805cb --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/beta/disable-auto-update.patch @@ -0,0 +1,31 @@ +diff --git a/bin/flutter b/bin/flutter +index e0c18e235..2c3fb7ddd 100755 +--- a/bin/flutter ++++ b/bin/flutter +@@ -185,8 +185,6 @@ fi + # FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS" + # FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432" + +-(upgrade_flutter) 3< "$PROG_NAME" +- + # FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as + # separate space-separated args. + "$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@" +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 99455ae64..f5b0cb59c 100644 +--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart ++++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +@@ -301,13 +301,6 @@ class FlutterCommandRunner extends CommandRunner { + } + + _checkFlutterCopy(); +- try { +- await globals.flutterVersion.ensureVersionFile(); +- } on FileSystemException catch (e) { +- globals.printError('Failed to write the version file to the artifact cache: "$e".'); +- globals.printError('Please ensure you have permissions in the artifact cache directory.'); +- throwToolExit('Failed to write the version file'); +- } + final bool machineFlag = topLevelResults['machine'] as bool; + if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool && !machineFlag) { + await globals.flutterVersion.checkFlutterVersionFreshness(); diff --git a/pkgs/development/compilers/flutter/patches/beta/move-cache.patch b/pkgs/development/compilers/flutter/patches/beta/move-cache.patch new file mode 100644 index 00000000000..303f8dd3739 --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/beta/move-cache.patch @@ -0,0 +1,63 @@ +diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart +index 8e511eefd..fbc7d6ac3 100644 +--- a/dev/devicelab/lib/framework/runner.dart ++++ b/dev/devicelab/lib/framework/runner.dart +@@ -126,7 +126,7 @@ Future cleanupSystem() async { + print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)'); + final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew'; + final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.'); +- recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir); ++ recursiveCopy(Directory(path.join(homeDirPath, '.cache', 'flutter', 'artifacts', 'gradle_wrapper')), tempDir); + copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'app', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper'))); + if (!Platform.isWindows) { + await exec( +diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart +index 79b06949f..9040ba0a8 100644 +--- a/packages/flutter_tools/lib/src/asset.dart ++++ b/packages/flutter_tools/lib/src/asset.dart +@@ -6,6 +6,7 @@ import 'dart:async'; + + import 'package:yaml/yaml.dart'; + ++import 'base/common.dart'; + import 'base/context.dart'; + import 'base/file_system.dart'; + import 'base/utils.dart'; +@@ -325,7 +326,7 @@ List<_Asset> _getMaterialAssets(String fontSet) { + for (final Map font in family['fonts']) { + final Uri entryUri = globals.fs.path.toUri(font['asset'] as String); + result.add(_Asset( +- baseDir: globals.fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'), ++ baseDir: globals.fs.path.join(homeDirPath, '.cache', 'flutter', 'artifacts', 'material_fonts'), + relativeUri: Uri(path: entryUri.pathSegments.last), + entryUri: entryUri, + )); +diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart +index 715189938..5afb2a0db 100644 +--- a/packages/flutter_tools/lib/src/cache.dart ++++ b/packages/flutter_tools/lib/src/cache.dart +@@ -189,8 +189,14 @@ class Cache { + return; + } + assert(_lock == null); ++ ++ final Directory dir = globals.fs.directory(globals.fs.path.join(homeDirPath, '.cache', 'flutter')); ++ if (!dir.existsSync()) { ++ dir.createSync(recursive: true); ++ os.chmod(dir, '755'); ++ } + final File lockFile = +- globals.fs.file(globals.fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile')); ++ globals.fs.file(globals.fs.path.join(homeDirPath, '.cache', 'flutter', 'lockfile')); + try { + _lock = lockFile.openSync(mode: FileMode.write); + } on FileSystemException catch (e) { +@@ -290,7 +296,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(homeDirPath, '.cache', 'flutter')); + } + } + diff --git a/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch new file mode 100644 index 00000000000..42c09c805cb --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch @@ -0,0 +1,31 @@ +diff --git a/bin/flutter b/bin/flutter +index e0c18e235..2c3fb7ddd 100755 +--- a/bin/flutter ++++ b/bin/flutter +@@ -185,8 +185,6 @@ fi + # FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS" + # FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432" + +-(upgrade_flutter) 3< "$PROG_NAME" +- + # FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as + # separate space-separated args. + "$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@" +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 99455ae64..f5b0cb59c 100644 +--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart ++++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +@@ -301,13 +301,6 @@ class FlutterCommandRunner extends CommandRunner { + } + + _checkFlutterCopy(); +- try { +- await globals.flutterVersion.ensureVersionFile(); +- } on FileSystemException catch (e) { +- globals.printError('Failed to write the version file to the artifact cache: "$e".'); +- globals.printError('Please ensure you have permissions in the artifact cache directory.'); +- throwToolExit('Failed to write the version file'); +- } + final bool machineFlag = topLevelResults['machine'] as bool; + if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool && !machineFlag) { + await globals.flutterVersion.checkFlutterVersionFreshness(); diff --git a/pkgs/development/compilers/flutter/patches/dev/move-cache.patch b/pkgs/development/compilers/flutter/patches/dev/move-cache.patch new file mode 100644 index 00000000000..4672d4c625d --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/dev/move-cache.patch @@ -0,0 +1,63 @@ +diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart +index 8e511eefd..fbc7d6ac3 100644 +--- a/dev/devicelab/lib/framework/runner.dart ++++ b/dev/devicelab/lib/framework/runner.dart +@@ -126,7 +126,7 @@ Future cleanupSystem() async { + print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)'); + final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew'; + final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.'); +- recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir); ++ recursiveCopy(Directory(path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter', 'artifacts', 'gradle_wrapper')), tempDir); + copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'app', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper'))); + if (!Platform.isWindows) { + await exec( +diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart +index 79b06949f..9040ba0a8 100644 +--- a/packages/flutter_tools/lib/src/asset.dart ++++ b/packages/flutter_tools/lib/src/asset.dart +@@ -6,6 +6,7 @@ import 'dart:async'; + + import 'package:yaml/yaml.dart'; + ++import 'base/common.dart'; + import 'base/context.dart'; + import 'base/file_system.dart'; + import 'base/utils.dart'; +@@ -325,7 +326,7 @@ List<_Asset> _getMaterialAssets(String fontSet) { + for (final Map font in family['fonts']) { + final Uri entryUri = globals.fs.path.toUri(font['asset'] as String); + result.add(_Asset( +- baseDir: globals.fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'), ++ baseDir: globals.fs.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter', 'artifacts', 'material_fonts'), + relativeUri: Uri(path: entryUri.pathSegments.last), + entryUri: entryUri, + )); +diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart +index 715189938..5afb2a0db 100644 +--- a/packages/flutter_tools/lib/src/cache.dart ++++ b/packages/flutter_tools/lib/src/cache.dart +@@ -189,8 +189,14 @@ class Cache { + return; + } + assert(_lock == null); ++ ++ final Directory dir = globals.fs.directory(globals.fs.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter')); ++ if (!dir.existsSync()) { ++ dir.createSync(recursive: true); ++ globals.os.chmod(dir, '755'); ++ } + final File lockFile = +- globals.fs.file(globals.fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile')); ++ globals.fs.file(globals.fs.path.join(globals.fsUtils.homeDirPath, '.cache', 'flutter', 'lockfile')); + try { + _lock = lockFile.openSync(mode: FileMode.write); + } on FileSystemException catch (e) { +@@ -290,7 +296,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/stable/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/stable/disable-auto-update.patch new file mode 100644 index 00000000000..16fe504595f --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/stable/disable-auto-update.patch @@ -0,0 +1,31 @@ +diff --git a/bin/flutter b/bin/flutter +index 3955f8f39..1e7573d30 100755 +--- a/bin/flutter ++++ b/bin/flutter +@@ -185,8 +185,6 @@ fi + # FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS" + # FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432" + +-(upgrade_flutter) 3< "$PROG_NAME" +- + # FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as + # separate space-separated args. + "$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@" +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 5e45819d9..ab748b059 100644 +--- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart ++++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +@@ -377,13 +377,6 @@ class FlutterCommandRunner extends CommandRunner { + } + + _checkFlutterCopy(); +- try { +- await FlutterVersion.instance.ensureVersionFile(); +- } on FileSystemException catch (e) { +- printError('Failed to write the version file to the artifact cache: "$e".'); +- printError('Please ensure you have permissions in the artifact cache directory.'); +- throwToolExit('Failed to write the version file'); +- } + if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool) { + await FlutterVersion.instance.checkFlutterVersionFreshness(); + } diff --git a/pkgs/development/compilers/flutter/patches/stable/move-cache.patch b/pkgs/development/compilers/flutter/patches/stable/move-cache.patch new file mode 100644 index 00000000000..e5719a2867f --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/stable/move-cache.patch @@ -0,0 +1,63 @@ +diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart +index 9fae74726..d88d6ecbb 100644 +--- a/dev/devicelab/lib/framework/runner.dart ++++ b/dev/devicelab/lib/framework/runner.dart +@@ -126,7 +126,7 @@ Future cleanupSystem() async { + print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)'); + final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew'; + final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.'); +- recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir); ++ recursiveCopy(Directory(path.join(homeDirPath, '.cache', 'flutter', 'artifacts', 'gradle_wrapper')), tempDir); + copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'app', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper'))); + if (!Platform.isWindows) { + await exec( +diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart +index e6216c737..5ab497092 100644 +--- a/packages/flutter_tools/lib/src/asset.dart ++++ b/packages/flutter_tools/lib/src/asset.dart +@@ -6,6 +6,7 @@ import 'dart:async'; + + import 'package:yaml/yaml.dart'; + ++import 'base/common.dart'; + import 'base/context.dart'; + import 'base/file_system.dart'; + import 'base/platform.dart'; +@@ -326,7 +327,7 @@ List<_Asset> _getMaterialAssets(String fontSet) { + for (Map font in family['fonts']) { + final Uri entryUri = fs.path.toUri(font['asset'] as String); + result.add(_Asset( +- baseDir: fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'), ++ baseDir: fs.path.join(homeDirPath, '.cache', 'flutter', 'artifacts', 'material_fonts'), + relativeUri: Uri(path: entryUri.pathSegments.last), + entryUri: entryUri, + )); +diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart +index 5e1950b56..45585f9c0 100644 +--- a/packages/flutter_tools/lib/src/cache.dart ++++ b/packages/flutter_tools/lib/src/cache.dart +@@ -164,8 +164,14 @@ class Cache { + return; + } + assert(_lock == null); ++ ++ final Directory dir = fs.directory(fs.path.join(homeDirPath, '.cache', 'flutter')); ++ if (!dir.existsSync()) { ++ dir.createSync(recursive: true); ++ os.chmod(dir, '755'); ++ } + final File lockFile = +- fs.file(fs.path.join(flutterRoot, 'bin', 'cache', 'lockfile')); ++ fs.file(fs.path.join(homeDirPath, '.cache', 'flutter', 'lockfile')); + try { + _lock = lockFile.openSync(mode: FileMode.write); + } on FileSystemException catch (e) { +@@ -239,7 +245,7 @@ class Cache { + if (_rootOverride != null) { + return fs.directory(fs.path.join(_rootOverride.path, 'bin', 'cache')); + } else { +- return fs.directory(fs.path.join(flutterRoot, 'bin', 'cache')); ++ return fs.directory(fs.path.join(homeDirPath, '.cache', 'flutter')); + } + } + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0341fd97bc0..546c2a64b4e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8181,6 +8181,10 @@ in inherit (darwin.apple_sdk.frameworks) Security; }; + flutterPackages = + recurseIntoAttrs (callPackage ../development/compilers/flutter { }); + flutter = flutterPackages.stable; + fpc = callPackage ../development/compilers/fpc { }; gambit = callPackage ../development/compilers/gambit { stdenv = gccStdenv; }; From 4e0d07f6d74022a2fe9c1a9461acdb9da3ca872e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20Rivi=C3=A8re?= Date: Sun, 29 Mar 2020 14:10:26 +0200 Subject: [PATCH 2/2] flutter: symlink common patches --- .../patches/dev/disable-auto-update.patch | 32 +------------------ 1 file changed, 1 insertion(+), 31 deletions(-) mode change 100644 => 120000 pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch diff --git a/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch deleted file mode 100644 index 42c09c805cb..00000000000 --- a/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff --git a/bin/flutter b/bin/flutter -index e0c18e235..2c3fb7ddd 100755 ---- a/bin/flutter -+++ b/bin/flutter -@@ -185,8 +185,6 @@ fi - # FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS" - # FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432" - --(upgrade_flutter) 3< "$PROG_NAME" -- - # FLUTTER_TOOL_ARGS isn't quoted below, because it is meant to be considered as - # separate space-separated args. - "$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" $FLUTTER_TOOL_ARGS "$SNAPSHOT_PATH" "$@" -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 99455ae64..f5b0cb59c 100644 ---- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart -+++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart -@@ -301,13 +301,6 @@ class FlutterCommandRunner extends CommandRunner { - } - - _checkFlutterCopy(); -- try { -- await globals.flutterVersion.ensureVersionFile(); -- } on FileSystemException catch (e) { -- globals.printError('Failed to write the version file to the artifact cache: "$e".'); -- globals.printError('Please ensure you have permissions in the artifact cache directory.'); -- throwToolExit('Failed to write the version file'); -- } - final bool machineFlag = topLevelResults['machine'] as bool; - if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool && !machineFlag) { - await globals.flutterVersion.checkFlutterVersionFreshness(); diff --git a/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch new file mode 120000 index 00000000000..2c92799f3bb --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/dev/disable-auto-update.patch @@ -0,0 +1 @@ +../beta/disable-auto-update.patch \ No newline at end of file