flutter: Remove FLUTTER_CACHE_DIR
This commit is contained in:
parent
981831870d
commit
d8b20d93ad
@ -1,5 +1,6 @@
|
||||
{ lib
|
||||
, runCommand
|
||||
, xorg
|
||||
, cacert
|
||||
, unzip
|
||||
|
||||
@ -19,17 +20,16 @@ let
|
||||
"fuchsia"
|
||||
"universal"
|
||||
];
|
||||
|
||||
flutter' = flutter.override {
|
||||
# Use a version of Flutter with just enough capabilities to download
|
||||
# artifacts.
|
||||
supportedTargetPlatforms = [ ];
|
||||
};
|
||||
in
|
||||
runCommand "flutter-artifacts-${platform}"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
(flutter.override {
|
||||
# Use a version of Flutter with just enough capabilities to download
|
||||
# artifacts.
|
||||
supportedTargetPlatforms = [ ];
|
||||
})
|
||||
unzip
|
||||
];
|
||||
nativeBuildInputs = [ xorg.lndir flutter' unzip ];
|
||||
|
||||
NIX_FLUTTER_TOOLS_VM_OPTIONS = "--root-certs-file=${cacert}/etc/ssl/certs/ca-bundle.crt";
|
||||
|
||||
@ -41,6 +41,14 @@ runCommand "flutter-artifacts-${platform}"
|
||||
inherit platform;
|
||||
};
|
||||
} ''
|
||||
mkdir -p "$out"
|
||||
HOME="$NIX_BUILD_TOP" FLUTTER_CACHE_DIR="$out" flutter precache -v '--${platform}' ${builtins.concatStringsSep " " (map (p: "'--no-${p}'") (lib.remove platform platforms))}
|
||||
export FLUTTER_ROOT="$NIX_BUILD_TOP"
|
||||
lndir -silent '${flutter'}' "$FLUTTER_ROOT"
|
||||
rm -rf "$FLUTTER_ROOT/bin/cache"
|
||||
mkdir "$FLUTTER_ROOT/bin/cache"
|
||||
|
||||
HOME="$(mktemp -d)" flutter precache -v '--${platform}' ${builtins.concatStringsSep " " (map (p: "'--no-${p}'") (lib.remove platform platforms))}
|
||||
rm -r "$FLUTTER_ROOT/bin/cache/lockfile"
|
||||
find "$FLUTTER_ROOT" -type l -lname '${flutter'}/*' -delete
|
||||
|
||||
cp -r bin/cache "$out"
|
||||
''
|
||||
|
@ -1,53 +0,0 @@
|
||||
diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart
|
||||
index dd80b1e46e..8e54517765 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)
|
||||
@@ -318,8 +319,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) {
|
||||
@@ -378,8 +384,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}');
|
||||
}
|
||||
diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart
|
||||
index 1c31c1b5db..76c7210d3b 100644
|
||||
--- a/packages/flutter_tools/lib/src/cache.dart
|
||||
+++ b/packages/flutter_tools/lib/src/cache.dart
|
||||
@@ -529,6 +529,11 @@ class Cache {
|
||||
|
||||
/// Return the top-level directory in the cache; this is `bin/cache`.
|
||||
Directory getRoot() {
|
||||
+ const Platform platform = LocalPlatform();
|
||||
+ if (platform.environment.containsKey('FLUTTER_CACHE_DIR')) {
|
||||
+ return _fileSystem.directory(platform.environment['FLUTTER_CACHE_DIR']);
|
||||
+ }
|
||||
+
|
||||
if (_rootOverride != null) {
|
||||
return _fileSystem.directory(_fileSystem.path.join(_rootOverride!.path, 'bin', 'cache'));
|
||||
} else {
|
@ -67,11 +67,8 @@ let
|
||||
|
||||
# By default, Flutter stores downloaded files (such as the Pub cache) in the SDK directory.
|
||||
# Wrap it to ensure that it does not do that, preferring home directories instead.
|
||||
# The sh file `$out/bin/internal/shared.sh` runs when launching Flutter and calls `"$FLUTTER_ROOT/bin/cache/` instead of our environment variable `FLUTTER_CACHE_DIR`.
|
||||
# We do not patch it since the script doesn't require engine artifacts(which are the only thing not added by the unwrapped derivation), so it shouldn't fail, and patching it will just be harder to maintain.
|
||||
immutableFlutter = writeShellScript "flutter_immutable" ''
|
||||
export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"}
|
||||
export FLUTTER_CACHE_DIR=''${FLUTTER_CACHE_DIR:-'${cacheDir}/bin/cache'}
|
||||
${flutter}/bin/flutter "$@"
|
||||
'';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user