From ee289896a7cd0ea4d8a34f3cc5ca282a98ec3e54 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 22 Oct 2023 17:21:36 +1100 Subject: [PATCH 01/34] flutter: Build flutter_tools with buildDartApplication --- .../development/compilers/flutter/default.nix | 51 +- .../compilers/flutter/flutter-tools.nix | 29 + .../development/compilers/flutter/flutter.nix | 48 +- .../flutter/lockfiles/stable/deps.json | 1020 +++++++++++++++++ .../flutter/lockfiles/stable/pubspec.lock | 677 +++++++++++ 5 files changed, 1763 insertions(+), 62 deletions(-) create mode 100644 pkgs/development/compilers/flutter/flutter-tools.nix create mode 100644 pkgs/development/compilers/flutter/lockfiles/stable/deps.json create mode 100644 pkgs/development/compilers/flutter/lockfiles/stable/pubspec.lock diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index ff18036677a1..09bf098268a3 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -1,14 +1,24 @@ -{ callPackage, fetchzip, dart, lib, stdenv }: +{ callPackage, fetchzip, fetchFromGitHub, dart, lib, stdenv }: let mkCustomFlutter = args: callPackage ./flutter.nix args; wrapFlutter = flutter: callPackage ./wrapper.nix { inherit flutter; }; getPatches = dir: let files = builtins.attrNames (builtins.readDir dir); in map (f: dir + ("/" + f)) files; - mkFlutter = { version, engineVersion, dartVersion, flutterHash, dartHash, patches }: + mkFlutter = + { version + , engineVersion + , dartVersion + , flutterHash + , dartHash + , patches + , pubspecLockFile + , vendorHash + , depsListFile + }: let args = { - inherit version engineVersion patches; + inherit version engineVersion patches pubspecLockFile vendorHash depsListFile; dart = dart.override { version = dartVersion; @@ -31,24 +41,13 @@ let }; }; }; - src = { - x86_64-linux = fetchzip { - url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${version}-stable.tar.xz"; - sha256 = flutterHash.x86_64-linux; - }; - aarch64-linux = fetchzip { - url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${version}-stable.tar.xz"; - sha256 = flutterHash.aarch64-linux; - }; - x86_64-darwin = fetchzip { - url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_${version}-stable.zip"; - sha256 = flutterHash.x86_64-darwin; - }; - aarch64-darwin = fetchzip { - url = "https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_arm64_${version}-stable.zip"; - sha256 = flutterHash.aarch64-darwin; - }; - }.${stdenv.hostPlatform.system}; + src = fetchFromGitHub { + owner = "flutter"; + repo = "flutter"; + rev = version; + leaveDotGit = true; + hash = flutterHash; + }; }; in (mkCustomFlutter args).overrideAttrs (prev: next: { @@ -83,12 +82,10 @@ in x86_64-darwin = "sha256-BchKowKd6BscVuk/dXibcQzdFkW9//GDfll77mHEI4M="; aarch64-darwin = "sha256-9yrx09vYrOTmdqkfJI7mfh7DI1/rg67tPlf82m5+iKI="; }; - flutterHash = rec { - x86_64-linux = "sha256-ouI1gjcynSQfPTnfTVXQ4r/NEDdhmzUsKdcALLRiCbg="; - aarch64-linux = x86_64-linux; - x86_64-darwin = "sha256-k6KNazP/I71zG5mbx3iEtXBJ8EZi9Qq+7PgL/HAJrgE="; - aarch64-darwin = "sha256-Duvw8EqrGb3PmBHBH/prZjyij2xJd9sLkNfPRYpC0pQ="; - }; + flutterHash = "sha256-jFroBAlYGqcxuV/DKIvnhR11dQyPI0lm0wwhwokAoB0="; patches = flutter3Patches; + pubspecLockFile = ./lockfiles/stable/pubspec.lock; + vendorHash = "sha256-lsFOvvmhszBcFb9XvabpqfL2Ek4wjhmB0OrcWUOURFQ="; + depsListFile = ./lockfiles/stable/deps.json; }; } diff --git a/pkgs/development/compilers/flutter/flutter-tools.nix b/pkgs/development/compilers/flutter/flutter-tools.nix new file mode 100644 index 000000000000..25e2cb3d670b --- /dev/null +++ b/pkgs/development/compilers/flutter/flutter-tools.nix @@ -0,0 +1,29 @@ +{ buildDartApplication +, dart +, version +, flutterSrc +, pubspecLockFile +, vendorHash +, depsListFile +}: + +buildDartApplication.override { inherit dart; } rec { + pname = "flutter-tools"; + inherit version; + dartOutputType = "kernel"; + + src = flutterSrc; + sourceRoot = "source/packages/flutter_tools"; + + dartEntryPoints."flutter_tools.snapshot" = "bin/flutter_tools.dart"; + + # The Dart wrapper launchers are useless for the Flutter tool - it is designed + # to be launched from a snapshot by the SDK. + postInstall = '' + pushd "$out" + rm ${builtins.concatStringsSep " " (builtins.attrNames dartEntryPoints)} + popd + ''; + + inherit pubspecLockFile vendorHash depsListFile; +} diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index da45fee420d0..3cc230b7b205 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -3,21 +3,29 @@ , patches , dart , src +, pubspecLockFile +, vendorHash +, depsListFile , lib , stdenv +, callPackage , darwin , git , which }: let + tools = callPackage ./flutter-tools.nix { + inherit dart version; + flutterSrc = src; + inherit pubspecLockFile vendorHash depsListFile; + }; + unwrapped = stdenv.mkDerivation { name = "flutter-${version}-unwrapped"; inherit src patches version; - outputs = [ "out" "cache" ]; - buildInputs = [ git ]; nativeBuildInputs = [ ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ]; @@ -35,45 +43,15 @@ let buildPhase = '' export FLUTTER_ROOT="$(pwd)" - export FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools" - export SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart" + mkdir -p "$FLUTTER_ROOT/bin/cache" export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" - export DART_SDK_PATH="${dart}" - - # The Flutter tool compilation requires dependencies to be cached, as there is no Internet access. - # Dart expects package caches to be mutable, and does not support composing cache directories. - # The packages cached during the build therefore cannot be easily used. They are provided through - # the derivation's "cache" output, though, in case they are needed. - # - # Note that non-cached packages will normally be fetched from the Internet when they are needed, so Flutter - # will function without an existing package cache as long as it has an Internet connection. - export PUB_CACHE="$cache" - - if [ -d .pub-preload-cache ]; then - ${dart}/bin/dart pub cache preload .pub-preload-cache/* - elif [ -d .pub-cache ]; then - mv .pub-cache "$PUB_CACHE" - else - echo 'ERROR: Failed to locate the Dart package cache required to build the Flutter tool.' - exit 1 - fi - - pushd "$FLUTTER_TOOLS_DIR" - ${dart}/bin/dart pub get --offline - popd - local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" - ${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" "$SCRIPT_PATH" echo "$revision" > "$STAMP_PATH" + ln -s '${tools}/share/flutter_tools.snapshot' "$SNAPSHOT_PATH" echo -n "${version}" > version - - # Certain prebuilts should be replaced with Nix-built (or at least Nix-patched) equivalents. - rm -r \ - $FLUTTER_ROOT/bin/cache/dart-sdk \ - $FLUTTER_ROOT/bin/cache/artifacts/engine ''; installPhase = '' @@ -101,7 +79,7 @@ let ''; passthru = { - inherit dart engineVersion; + inherit dart engineVersion tools; # The derivation containing the original Flutter SDK files. # When other derivations wrap this one, any unmodified files # found here should be included as-is, for tooling compatibility. diff --git a/pkgs/development/compilers/flutter/lockfiles/stable/deps.json b/pkgs/development/compilers/flutter/lockfiles/stable/deps.json new file mode 100644 index 000000000000..30924f7d513b --- /dev/null +++ b/pkgs/development/compilers/flutter/lockfiles/stable/deps.json @@ -0,0 +1,1020 @@ +[ + { + "name": "flutter_tools", + "version": "0.0.0", + "kind": "root", + "source": "root", + "dependencies": [ + "archive", + "args", + "browser_launcher", + "dds", + "dwds", + "completion", + "coverage", + "crypto", + "file", + "flutter_template_images", + "html", + "http", + "intl", + "meta", + "multicast_dns", + "mustache_template", + "package_config", + "process", + "fake_async", + "stack_trace", + "usage", + "webdriver", + "webkit_inspection_protocol", + "xml", + "yaml", + "native_stack_traces", + "shelf", + "vm_snapshot_analysis", + "uuid", + "web_socket_channel", + "stream_channel", + "shelf_web_socket", + "shelf_static", + "pub_semver", + "pool", + "path", + "mime", + "logging", + "http_multi_server", + "convert", + "async", + "unified_analytics", + "test_api", + "test_core", + "vm_service", + "standard_message_codec", + "_fe_analyzer_shared", + "analyzer", + "boolean_selector", + "built_collection", + "built_value", + "clock", + "csslib", + "dap", + "dds_service_extensions", + "devtools_shared", + "fixnum", + "frontend_server_client", + "glob", + "http_parser", + "io", + "js", + "json_rpc_2", + "matcher", + "petitparser", + "platform", + "shelf_packages_handler", + "shelf_proxy", + "source_map_stack_trace", + "source_maps", + "source_span", + "sse", + "string_scanner", + "sync_http", + "term_glyph", + "typed_data", + "watcher", + "collection", + "file_testing", + "pubspec_parse", + "checked_yaml", + "json_annotation", + "node_preamble", + "test" + ] + }, + { + "name": "test", + "version": "1.24.3", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "analyzer", + "async", + "boolean_selector", + "collection", + "coverage", + "http_multi_server", + "io", + "js", + "node_preamble", + "package_config", + "path", + "pool", + "shelf", + "shelf_packages_handler", + "shelf_static", + "shelf_web_socket", + "source_span", + "stack_trace", + "stream_channel", + "typed_data", + "web_socket_channel", + "webkit_inspection_protocol", + "yaml", + "test_api", + "test_core", + "matcher" + ] + }, + { + "name": "matcher", + "version": "0.12.16", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "meta", + "stack_trace", + "term_glyph", + "test_api" + ] + }, + { + "name": "test_api", + "version": "0.6.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "boolean_selector", + "collection", + "meta", + "source_span", + "stack_trace", + "stream_channel", + "string_scanner", + "term_glyph" + ] + }, + { + "name": "term_glyph", + "version": "1.2.1", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "string_scanner", + "version": "1.2.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "source_span" + ] + }, + { + "name": "source_span", + "version": "1.10.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "path", + "term_glyph" + ] + }, + { + "name": "path", + "version": "1.8.3", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "collection", + "version": "1.17.2", + "kind": "dev", + "source": "hosted", + "dependencies": [] + }, + { + "name": "stream_channel", + "version": "2.1.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async" + ] + }, + { + "name": "async", + "version": "2.11.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "meta" + ] + }, + { + "name": "meta", + "version": "1.9.1", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "stack_trace", + "version": "1.11.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "path" + ] + }, + { + "name": "boolean_selector", + "version": "2.1.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "source_span", + "string_scanner" + ] + }, + { + "name": "test_core", + "version": "0.5.3", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "analyzer", + "async", + "args", + "boolean_selector", + "collection", + "coverage", + "frontend_server_client", + "glob", + "io", + "meta", + "package_config", + "path", + "pool", + "source_map_stack_trace", + "source_maps", + "source_span", + "stack_trace", + "stream_channel", + "vm_service", + "yaml", + "test_api" + ] + }, + { + "name": "yaml", + "version": "3.1.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "source_span", + "string_scanner" + ] + }, + { + "name": "vm_service", + "version": "11.7.1", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "source_maps", + "version": "0.10.12", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "source_span" + ] + }, + { + "name": "source_map_stack_trace", + "version": "2.1.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "path", + "source_maps", + "stack_trace" + ] + }, + { + "name": "pool", + "version": "1.5.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "stack_trace" + ] + }, + { + "name": "package_config", + "version": "2.1.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "path" + ] + }, + { + "name": "io", + "version": "1.0.4", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "meta", + "path", + "string_scanner" + ] + }, + { + "name": "glob", + "version": "2.1.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "collection", + "file", + "path", + "string_scanner" + ] + }, + { + "name": "file", + "version": "6.1.4", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "meta", + "path" + ] + }, + { + "name": "frontend_server_client", + "version": "3.2.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "path" + ] + }, + { + "name": "coverage", + "version": "1.6.3", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "args", + "logging", + "package_config", + "path", + "source_maps", + "stack_trace", + "vm_service" + ] + }, + { + "name": "logging", + "version": "1.2.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "args", + "version": "2.4.2", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "analyzer", + "version": "5.13.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "_fe_analyzer_shared", + "collection", + "convert", + "crypto", + "glob", + "meta", + "package_config", + "path", + "pub_semver", + "source_span", + "watcher", + "yaml" + ] + }, + { + "name": "watcher", + "version": "1.1.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "path" + ] + }, + { + "name": "pub_semver", + "version": "2.1.4", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "meta" + ] + }, + { + "name": "crypto", + "version": "3.0.3", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "typed_data" + ] + }, + { + "name": "typed_data", + "version": "1.3.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection" + ] + }, + { + "name": "convert", + "version": "3.1.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "typed_data" + ] + }, + { + "name": "_fe_analyzer_shared", + "version": "61.0.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "webkit_inspection_protocol", + "version": "1.2.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "logging" + ] + }, + { + "name": "web_socket_channel", + "version": "2.4.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "crypto", + "stream_channel" + ] + }, + { + "name": "shelf_web_socket", + "version": "1.0.4", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "shelf", + "stream_channel", + "web_socket_channel" + ] + }, + { + "name": "shelf", + "version": "1.4.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "collection", + "http_parser", + "path", + "stack_trace", + "stream_channel" + ] + }, + { + "name": "http_parser", + "version": "4.0.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "source_span", + "string_scanner", + "typed_data" + ] + }, + { + "name": "shelf_static", + "version": "1.1.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "convert", + "http_parser", + "mime", + "path", + "shelf" + ] + }, + { + "name": "mime", + "version": "1.0.4", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "shelf_packages_handler", + "version": "3.0.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "path", + "shelf", + "shelf_static" + ] + }, + { + "name": "node_preamble", + "version": "2.0.2", + "kind": "dev", + "source": "hosted", + "dependencies": [] + }, + { + "name": "js", + "version": "0.6.7", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "http_multi_server", + "version": "3.2.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async" + ] + }, + { + "name": "json_annotation", + "version": "4.8.1", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "checked_yaml", + "version": "2.0.3", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "json_annotation", + "source_span", + "yaml" + ] + }, + { + "name": "pubspec_parse", + "version": "1.2.3", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "checked_yaml", + "collection", + "json_annotation", + "pub_semver", + "yaml" + ] + }, + { + "name": "file_testing", + "version": "3.0.0", + "kind": "dev", + "source": "hosted", + "dependencies": [ + "test" + ] + }, + { + "name": "sync_http", + "version": "0.3.1", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "sse", + "version": "4.1.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "collection", + "js", + "logging", + "pool", + "shelf", + "stream_channel" + ] + }, + { + "name": "shelf_proxy", + "version": "1.0.4", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "http", + "path", + "shelf" + ] + }, + { + "name": "http", + "version": "0.13.6", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "http_parser", + "meta" + ] + }, + { + "name": "platform", + "version": "3.1.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "petitparser", + "version": "5.4.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "json_rpc_2", + "version": "3.0.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "stack_trace", + "stream_channel" + ] + }, + { + "name": "fixnum", + "version": "1.1.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "devtools_shared", + "version": "2.24.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "path", + "shelf", + "usage", + "vm_service", + "webkit_inspection_protocol" + ] + }, + { + "name": "usage", + "version": "4.1.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "meta", + "path" + ] + }, + { + "name": "dds_service_extensions", + "version": "1.5.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "dap", + "vm_service" + ] + }, + { + "name": "dap", + "version": "1.0.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "csslib", + "version": "1.0.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "source_span" + ] + }, + { + "name": "clock", + "version": "1.1.1", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "built_value", + "version": "8.6.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "built_collection", + "collection", + "fixnum", + "meta" + ] + }, + { + "name": "built_collection", + "version": "5.1.1", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "standard_message_codec", + "version": "0.0.1+3", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "unified_analytics", + "version": "2.0.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "clock", + "file", + "http", + "intl", + "meta", + "path" + ] + }, + { + "name": "intl", + "version": "0.18.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "clock", + "meta", + "path" + ] + }, + { + "name": "uuid", + "version": "3.0.7", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "crypto" + ] + }, + { + "name": "vm_snapshot_analysis", + "version": "0.7.6", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "args", + "collection", + "path" + ] + }, + { + "name": "native_stack_traces", + "version": "0.5.6", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "args", + "path" + ] + }, + { + "name": "xml", + "version": "6.3.0", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "collection", + "meta", + "petitparser" + ] + }, + { + "name": "webdriver", + "version": "3.0.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "matcher", + "path", + "stack_trace", + "sync_http" + ] + }, + { + "name": "fake_async", + "version": "1.3.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "clock", + "collection" + ] + }, + { + "name": "process", + "version": "4.2.4", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "file", + "path", + "platform" + ] + }, + { + "name": "mustache_template", + "version": "2.0.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "multicast_dns", + "version": "0.3.2+3", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "meta" + ] + }, + { + "name": "html", + "version": "0.15.4", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "csslib", + "source_span" + ] + }, + { + "name": "flutter_template_images", + "version": "4.2.0", + "kind": "direct", + "source": "hosted", + "dependencies": [] + }, + { + "name": "completion", + "version": "1.0.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "args", + "logging", + "path" + ] + }, + { + "name": "dwds", + "version": "19.0.1+1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "async", + "built_collection", + "built_value", + "collection", + "crypto", + "dds", + "file", + "http", + "http_multi_server", + "logging", + "meta", + "package_config", + "path", + "pool", + "pub_semver", + "shelf", + "shelf_packages_handler", + "shelf_proxy", + "shelf_static", + "shelf_web_socket", + "source_maps", + "stack_trace", + "sse", + "uuid", + "vm_service", + "web_socket_channel", + "webkit_inspection_protocol" + ] + }, + { + "name": "dds", + "version": "2.9.0+hotfix", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "args", + "async", + "browser_launcher", + "collection", + "dds_service_extensions", + "dap", + "devtools_shared", + "http_multi_server", + "json_rpc_2", + "meta", + "path", + "shelf_proxy", + "shelf_static", + "shelf_web_socket", + "shelf", + "sse", + "stack_trace", + "stream_channel", + "vm_service", + "web_socket_channel" + ] + }, + { + "name": "browser_launcher", + "version": "1.1.1", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "path", + "webkit_inspection_protocol" + ] + }, + { + "name": "archive", + "version": "3.3.2", + "kind": "direct", + "source": "hosted", + "dependencies": [ + "crypto", + "path" + ] + } +] diff --git a/pkgs/development/compilers/flutter/lockfiles/stable/pubspec.lock b/pkgs/development/compilers/flutter/lockfiles/stable/pubspec.lock new file mode 100644 index 000000000000..8b11ae73ee03 --- /dev/null +++ b/pkgs/development/compilers/flutter/lockfiles/stable/pubspec.lock @@ -0,0 +1,677 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: "direct main" + description: + name: _fe_analyzer_shared + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a + url: "https://pub.dev" + source: hosted + version: "61.0.0" + analyzer: + dependency: "direct main" + description: + name: analyzer + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 + url: "https://pub.dev" + source: hosted + version: "5.13.0" + archive: + dependency: "direct main" + description: + name: archive + sha256: "80e5141fafcb3361653ce308776cfd7d45e6e9fbb429e14eec571382c0c5fecb" + url: "https://pub.dev" + source: hosted + version: "3.3.2" + args: + dependency: "direct main" + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: "direct main" + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: "direct main" + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + browser_launcher: + dependency: "direct main" + description: + name: browser_launcher + sha256: "6ee4c6b1f68a42e769ef6e663c4f56708522f7bce9d2ab6e308a37b612ffa4ec" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + built_collection: + dependency: "direct main" + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: "direct main" + description: + name: built_value + sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166" + url: "https://pub.dev" + source: hosted + version: "8.6.1" + checked_yaml: + dependency: "direct dev" + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + clock: + dependency: "direct main" + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: "direct dev" + description: + name: collection + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" + source: hosted + version: "1.17.2" + completion: + dependency: "direct main" + description: + name: completion + sha256: f11b7a628e6c42b9edc9b0bc3aa490e2d930397546d2f794e8e1325909d11c60 + url: "https://pub.dev" + source: hosted + version: "1.0.1" + convert: + dependency: "direct main" + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + coverage: + dependency: "direct main" + description: + name: coverage + sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097" + url: "https://pub.dev" + source: hosted + version: "1.6.3" + crypto: + dependency: "direct main" + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + csslib: + dependency: "direct main" + description: + name: csslib + sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + dap: + dependency: "direct main" + description: + name: dap + sha256: "2120d4a8cbad45e5dbd518b713e8f064274e0a4c0e3edcaef1f4cf9ccbc90cd9" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + dds: + dependency: "direct main" + description: + name: dds + sha256: "397c3c80919ee187b2efc28205af3c0378b6b757ea6d059083dece145a2e31e9" + url: "https://pub.dev" + source: hosted + version: "2.9.0+hotfix" + dds_service_extensions: + dependency: "direct main" + description: + name: dds_service_extensions + sha256: "9ac669bef49a4c13ed62073685089be121200fb213800ec59c202e90d569ea44" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + devtools_shared: + dependency: "direct main" + description: + name: devtools_shared + sha256: ad58ac3a5df41adf08d0d6f0a4d73349533edcc383ee93a30ac3d0fd0bb6df49 + url: "https://pub.dev" + source: hosted + version: "2.24.0" + dwds: + dependency: "direct main" + description: + name: dwds + sha256: b6dad73ae56f00bff7647f531b9db018005f713328e816e7a277b544184e9170 + url: "https://pub.dev" + source: hosted + version: "19.0.1+1" + fake_async: + dependency: "direct main" + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + file: + dependency: "direct main" + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + file_testing: + dependency: "direct dev" + description: + name: file_testing + sha256: "0aaadb4025bd350403f4308ad6c4cea953278d9407814b8342558e4946840fb5" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + fixnum: + dependency: "direct main" + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + flutter_template_images: + dependency: "direct main" + description: + name: flutter_template_images + sha256: fd3e55af73c577b9e3f88d4080d3e366cb5c8ef3fbd50b94dfeca56bb0235df6 + url: "https://pub.dev" + source: hosted + version: "4.2.0" + frontend_server_client: + dependency: "direct main" + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + glob: + dependency: "direct main" + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + html: + dependency: "direct main" + description: + name: html + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" + url: "https://pub.dev" + source: hosted + version: "0.15.4" + http: + dependency: "direct main" + description: + name: http + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" + url: "https://pub.dev" + source: hosted + version: "0.13.6" + http_multi_server: + dependency: "direct main" + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: "direct main" + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + io: + dependency: "direct main" + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: "direct main" + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: "direct dev" + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" + json_rpc_2: + dependency: "direct main" + description: + name: json_rpc_2 + sha256: "5e469bffa23899edacb7b22787780068d650b106a21c76db3c49218ab7ca447e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + logging: + dependency: "direct main" + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + matcher: + dependency: "direct main" + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + meta: + dependency: "direct main" + description: + name: meta + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + mime: + dependency: "direct main" + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + multicast_dns: + dependency: "direct main" + description: + name: multicast_dns + sha256: "80e54aba906a7cc68fdc6a201e76b135af27155e2f8e958181d85e2b73786591" + url: "https://pub.dev" + source: hosted + version: "0.3.2+3" + mustache_template: + dependency: "direct main" + description: + name: mustache_template + sha256: a46e26f91445bfb0b60519be280555b06792460b27b19e2b19ad5b9740df5d1c + url: "https://pub.dev" + source: hosted + version: "2.0.0" + native_stack_traces: + dependency: "direct main" + description: + name: native_stack_traces + sha256: c797830b9910d13b0f4e70ddef15cde034214fe3bdb8092c4ea5ffad2f74013f + url: "https://pub.dev" + source: hosted + version: "0.5.6" + node_preamble: + dependency: "direct dev" + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: "direct main" + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: "direct main" + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + petitparser: + dependency: "direct main" + description: + name: petitparser + sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 + url: "https://pub.dev" + source: hosted + version: "5.4.0" + platform: + dependency: "direct main" + description: + name: platform + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + pool: + dependency: "direct main" + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + process: + dependency: "direct main" + description: + name: process + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" + source: hosted + version: "4.2.4" + pub_semver: + dependency: "direct main" + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: "direct dev" + description: + name: pubspec_parse + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + shelf: + dependency: "direct main" + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_packages_handler: + dependency: "direct main" + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_proxy: + dependency: "direct main" + description: + name: shelf_proxy + sha256: a71d2307f4393211930c590c3d2c00630f6c5a7a77edc1ef6436dfd85a6a7ee3 + url: "https://pub.dev" + source: hosted + version: "1.0.4" + shelf_static: + dependency: "direct main" + description: + name: shelf_static + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e + url: "https://pub.dev" + source: hosted + version: "1.1.2" + shelf_web_socket: + dependency: "direct main" + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + source_map_stack_trace: + dependency: "direct main" + description: + name: source_map_stack_trace + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + source_maps: + dependency: "direct main" + description: + name: source_maps + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" + url: "https://pub.dev" + source: hosted + version: "0.10.12" + source_span: + dependency: "direct main" + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + sse: + dependency: "direct main" + description: + name: sse + sha256: "3ff9088cac3f45aa8b91336f1962e3ea6c81baaba0bbba361c05f8aa7fb59442" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + stack_trace: + dependency: "direct main" + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + standard_message_codec: + dependency: "direct main" + description: + name: standard_message_codec + sha256: "906e66549f0ea90d87c5320e0b0f04738c5d14bc7fb121a15da31b60e84f5b15" + url: "https://pub.dev" + source: hosted + version: "0.0.1+3" + stream_channel: + dependency: "direct main" + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: "direct main" + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + sync_http: + dependency: "direct main" + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + term_glyph: + dependency: "direct main" + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test: + dependency: "direct dev" + description: + name: test + sha256: "13b41f318e2a5751c3169137103b60c584297353d4b1761b66029bae6411fe46" + url: "https://pub.dev" + source: hosted + version: "1.24.3" + test_api: + dependency: "direct main" + description: + name: test_api + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + test_core: + dependency: "direct main" + description: + name: test_core + sha256: "99806e9e6d95c7b059b7a0fc08f07fc53fabe54a829497f0d9676299f1e8637e" + url: "https://pub.dev" + source: hosted + version: "0.5.3" + typed_data: + dependency: "direct main" + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + unified_analytics: + dependency: "direct main" + description: + name: unified_analytics + sha256: "4f9f29e5fd357d68fce270e37c7ad9bb489ee20098529199d6bc786b2b624298" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + usage: + dependency: "direct main" + description: + name: usage + sha256: "0bdbde65a6e710343d02a56552eeaefd20b735e04bfb6b3ee025b6b22e8d0e15" + url: "https://pub.dev" + source: hosted + version: "4.1.1" + uuid: + dependency: "direct main" + description: + name: uuid + sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + url: "https://pub.dev" + source: hosted + version: "3.0.7" + vm_service: + dependency: "direct main" + description: + name: vm_service + sha256: c620a6f783fa22436da68e42db7ebbf18b8c44b9a46ab911f666ff09ffd9153f + url: "https://pub.dev" + source: hosted + version: "11.7.1" + vm_snapshot_analysis: + dependency: "direct main" + description: + name: vm_snapshot_analysis + sha256: "5a79b9fbb6be2555090f55b03b23907e75d44c3fd7bdd88da09848aa5a1914c8" + url: "https://pub.dev" + source: hosted + version: "0.7.6" + watcher: + dependency: "direct main" + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web_socket_channel: + dependency: "direct main" + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + webdriver: + dependency: "direct main" + description: + name: webdriver + sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + webkit_inspection_protocol: + dependency: "direct main" + description: + name: webkit_inspection_protocol + sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + xml: + dependency: "direct main" + description: + name: xml + sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84" + url: "https://pub.dev" + source: hosted + version: "6.3.0" + yaml: + dependency: "direct main" + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=3.0.0 <4.0.0" From 30170047b8e5155320adbaaa057bbb6ef71761c2 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 22 Oct 2023 18:20:09 +1100 Subject: [PATCH 02/34] flutter: Use deepClone = true for SDK repository --- pkgs/development/compilers/flutter/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 09bf098268a3..404738600e9e 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -45,7 +45,10 @@ let owner = "flutter"; repo = "flutter"; rev = version; - leaveDotGit = true; + # The Flutter SDK uses Git to obtain version information, + # and relies on many features that do not work with leaveDotGit alone. + # https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/version.dart + deepClone = true; hash = flutterHash; }; }; @@ -82,7 +85,7 @@ in x86_64-darwin = "sha256-BchKowKd6BscVuk/dXibcQzdFkW9//GDfll77mHEI4M="; aarch64-darwin = "sha256-9yrx09vYrOTmdqkfJI7mfh7DI1/rg67tPlf82m5+iKI="; }; - flutterHash = "sha256-jFroBAlYGqcxuV/DKIvnhR11dQyPI0lm0wwhwokAoB0="; + flutterHash = "sha256-s6JLDNHRBq3kZjA5vZHID9DQPNn/CZT2a3C3uvV/M6g="; patches = flutter3Patches; pubspecLockFile = ./lockfiles/stable/pubspec.lock; vendorHash = "sha256-lsFOvvmhszBcFb9XvabpqfL2Ek4wjhmB0OrcWUOURFQ="; From 00a11274d4c4685d587bb8e13c17ceab1148a4ad Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 22 Oct 2023 18:21:00 +1100 Subject: [PATCH 03/34] flutter: Include patches in flutter_tools snapshot --- pkgs/development/compilers/flutter/flutter-tools.nix | 7 +++++++ pkgs/development/compilers/flutter/flutter.nix | 1 + 2 files changed, 8 insertions(+) diff --git a/pkgs/development/compilers/flutter/flutter-tools.nix b/pkgs/development/compilers/flutter/flutter-tools.nix index 25e2cb3d670b..156cbf75588a 100644 --- a/pkgs/development/compilers/flutter/flutter-tools.nix +++ b/pkgs/development/compilers/flutter/flutter-tools.nix @@ -2,6 +2,7 @@ , dart , version , flutterSrc +, patches ? [ ] , pubspecLockFile , vendorHash , depsListFile @@ -14,6 +15,12 @@ buildDartApplication.override { inherit dart; } rec { src = flutterSrc; sourceRoot = "source/packages/flutter_tools"; + postUnpack = ''chmod -R u+w "$NIX_BUILD_TOP/source"''; + + inherit patches; + # The given patches are made for the entire SDK source tree. + prePatch = ''pushd "$NIX_BUILD_TOP/source"''; + postPatch = ''popd''; dartEntryPoints."flutter_tools.snapshot" = "bin/flutter_tools.dart"; diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 3cc230b7b205..714876fdb1b2 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -18,6 +18,7 @@ let tools = callPackage ./flutter-tools.nix { inherit dart version; flutterSrc = src; + inherit patches; inherit pubspecLockFile vendorHash depsListFile; }; From 175112a99621fc38faeacc4cdd36f7ded2209abe Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Sun, 22 Oct 2023 18:33:32 +1100 Subject: [PATCH 04/34] flutter: Remove hard dependency on Git --- pkgs/development/compilers/flutter/default.nix | 6 +----- pkgs/development/compilers/flutter/flutter.nix | 6 +++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index 404738600e9e..ca405c03a85d 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -45,10 +45,6 @@ let owner = "flutter"; repo = "flutter"; rev = version; - # The Flutter SDK uses Git to obtain version information, - # and relies on many features that do not work with leaveDotGit alone. - # https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/version.dart - deepClone = true; hash = flutterHash; }; }; @@ -85,7 +81,7 @@ in x86_64-darwin = "sha256-BchKowKd6BscVuk/dXibcQzdFkW9//GDfll77mHEI4M="; aarch64-darwin = "sha256-9yrx09vYrOTmdqkfJI7mfh7DI1/rg67tPlf82m5+iKI="; }; - flutterHash = "sha256-s6JLDNHRBq3kZjA5vZHID9DQPNn/CZT2a3C3uvV/M6g="; + flutterHash = "sha256-00G030FvZZTsdf9ruFs9jdIHcC5h+xpp4NlmL64qVZA="; patches = flutter3Patches; pubspecLockFile = ./lockfiles/stable/pubspec.lock; vendorHash = "sha256-lsFOvvmhszBcFb9XvabpqfL2Ek4wjhmB0OrcWUOURFQ="; diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 714876fdb1b2..a96da5bd39c6 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -62,6 +62,10 @@ let cp -r . $out ln -sf ${dart} $out/bin/cache/dart-sdk + # The Flutter CLI launcher checks for the existance of a .git directory. + # https://github.com/flutter/flutter/blob/3.13.8/bin/internal/shared.sh#L224 + mkdir -p "$out/.git" + runHook postInstall ''; @@ -74,7 +78,7 @@ let export HOME="$(mktemp -d)" $out/bin/flutter config --android-studio-dir $HOME $out/bin/flutter config --android-sdk $HOME - $out/bin/flutter --version | fgrep -q '${version}' + $out/bin/flutter --version | fgrep -q '${builtins.substring 0 10 engineVersion}' runHook postInstallCheck ''; From e22019bc2f7aafe8df2e70d29e8a4dbe444ad084 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 00:19:45 +1100 Subject: [PATCH 05/34] flutter: Allow overriding the FLUTTER_CACHE_DIR --- pkgs/development/compilers/flutter/wrapper.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index f525bcc7ab31..fd08c324ba3a 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -120,7 +120,7 @@ let # 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=${cacheDir} + export FLUTTER_CACHE_DIR=''${FLUTTER_CACHE_DIR:-'${cacheDir}'} ${flutter}/bin/flutter "$@" ''; From 075bbf494b4f3794aa4f942c316636384c333389 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 01:06:45 +1100 Subject: [PATCH 06/34] flutter: Use custom launchers --- .../development/compilers/flutter/flutter.nix | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index a96da5bd39c6..a02c9bb8d114 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -9,6 +9,7 @@ , lib , stdenv , callPackage +, makeWrapper , darwin , git , which @@ -28,7 +29,7 @@ let inherit src patches version; buildInputs = [ git ]; - nativeBuildInputs = [ ] + nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ]; preConfigure = '' @@ -43,15 +44,19 @@ let ''; buildPhase = '' - export FLUTTER_ROOT="$(pwd)" + # The flutter_tools package tries to run many Git commands. In most + # cases, unexpected output is handled gracefully, but commands are never + # expected to fail completely. A blank repository needs to be created. + if [ ! -d .git ]; then + git init -b nixpkgs + GIT_AUTHOR_NAME=Nixpkgs GIT_COMMITTER_NAME=Nixpkgs GIT_AUTHOR_EMAIL= GIT_COMMITTER_EMAIL= \ + git commit --allow-empty -m "Initial commit" + (. '${../../../build-support/fetchgit/deterministic-git}'; make_deterministic_repo .) + fi - mkdir -p "$FLUTTER_ROOT/bin/cache" - export SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot" - export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" - - local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" - echo "$revision" > "$STAMP_PATH" - ln -s '${tools}/share/flutter_tools.snapshot' "$SNAPSHOT_PATH" + mkdir -p bin/cache + echo "$(git rev-parse HEAD)" > bin/cache/flutter_tools.stamp + ln -s '${tools}/share/flutter_tools.snapshot' bin/cache/flutter_tools.snapshot echo -n "${version}" > version ''; @@ -62,9 +67,14 @@ let cp -r . $out ln -sf ${dart} $out/bin/cache/dart-sdk - # The Flutter CLI launcher checks for the existance of a .git directory. - # https://github.com/flutter/flutter/blob/3.13.8/bin/internal/shared.sh#L224 - mkdir -p "$out/.git" + # The regular launchers are designed to download/build/update SDK + # components, and are not very useful in Nix. + # Replace them with simple links and wrappers. + rm "$out/bin"/{dart,flutter} + ln -s "$out/bin/cache/dart-sdk/bin/dart" "$out/bin/dart" + makeWrapper "$out/bin/dart" "$out/bin/flutter" \ + --set-default FLUTTER_ROOT "$out" \ + --add-flags "--disable-dart-dev $out/bin/cache/flutter_tools.snapshot" runHook postInstall ''; From ec0c30d6d7b651ebe0546a68e8904ffafba7ef3e Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 02:37:41 +1100 Subject: [PATCH 07/34] flutter: Specify commit date for fake SDK repository --- pkgs/development/compilers/flutter/flutter.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index a02c9bb8d114..1f732f81476a 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -49,7 +49,9 @@ let # expected to fail completely. A blank repository needs to be created. if [ ! -d .git ]; then git init -b nixpkgs - GIT_AUTHOR_NAME=Nixpkgs GIT_COMMITTER_NAME=Nixpkgs GIT_AUTHOR_EMAIL= GIT_COMMITTER_EMAIL= \ + GIT_AUTHOR_NAME=Nixpkgs GIT_COMMITTER_NAME=Nixpkgs \ + GIT_AUTHOR_EMAIL= GIT_COMMITTER_EMAIL= \ + GIT_AUTHOR_DATE='1/1/1970 00:00:00 +0000' GIT_COMMITTER_DATE='1/1/1970 00:00:00 +0000' \ git commit --allow-empty -m "Initial commit" (. '${../../../build-support/fetchgit/deterministic-git}'; make_deterministic_repo .) fi From 2dc524e2a701e86a113f536fdd7f430afac183de Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 02:39:34 +1100 Subject: [PATCH 08/34] flutter: Remove any existing Dart SDK --- pkgs/development/compilers/flutter/flutter.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 1f732f81476a..6d011b6f45f9 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -67,6 +67,7 @@ let mkdir -p $out cp -r . $out + rm -rf $out/bin/cache/dart-sdk ln -sf ${dart} $out/bin/cache/dart-sdk # The regular launchers are designed to download/build/update SDK From 5f6d29a70aafa0b16a23ae207cc31a4c15b99557 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 02:51:25 +1100 Subject: [PATCH 09/34] flutter: Use JIT snapshot for flutter_tools --- .../compilers/flutter/flutter-tools.nix | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/flutter-tools.nix b/pkgs/development/compilers/flutter/flutter-tools.nix index 156cbf75588a..23864cd0f245 100644 --- a/pkgs/development/compilers/flutter/flutter-tools.nix +++ b/pkgs/development/compilers/flutter/flutter-tools.nix @@ -1,4 +1,6 @@ { buildDartApplication +, git +, which , dart , version , flutterSrc @@ -11,7 +13,12 @@ buildDartApplication.override { inherit dart; } rec { pname = "flutter-tools"; inherit version; - dartOutputType = "kernel"; + + # The SDK normally uses a JIT snapshot, so we do as well. + # Previously, we used a kernel snapshot - but this was found to cause + # extremely strange behaviour at runtime (observed in `flutter precache`), + # where certain functions would not execute properly. + dartOutputType = "jit-snapshot"; src = flutterSrc; sourceRoot = "source/packages/flutter_tools"; @@ -24,6 +31,17 @@ buildDartApplication.override { inherit dart; } rec { dartEntryPoints."flutter_tools.snapshot" = "bin/flutter_tools.dart"; + # When the JIT snapshot is being built, the application needs to run. + # It attempts to generate configuration files, and relies on a few external + # tools. + nativeBuildInputs = [ git which ]; + preConfigure = '' + export HOME=. + export FLUTTER_ROOT="$NIX_BUILD_TOP/source" + mkdir -p "$FLUTTER_ROOT/bin/cache" + ln -s '${dart}' "$FLUTTER_ROOT/bin/cache/dart-sdk" + ''; + # The Dart wrapper launchers are useless for the Flutter tool - it is designed # to be launched from a snapshot by the SDK. postInstall = '' From c3237a8d3828648267c8450b1f7d8ed6af531b30 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 02:57:39 +1100 Subject: [PATCH 10/34] flutter: Remove JIT explanation Turns out it was a patch that was causing the strange behaviour. --- pkgs/development/compilers/flutter/flutter-tools.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter-tools.nix b/pkgs/development/compilers/flutter/flutter-tools.nix index 23864cd0f245..bf673400b765 100644 --- a/pkgs/development/compilers/flutter/flutter-tools.nix +++ b/pkgs/development/compilers/flutter/flutter-tools.nix @@ -13,11 +13,6 @@ buildDartApplication.override { inherit dart; } rec { pname = "flutter-tools"; inherit version; - - # The SDK normally uses a JIT snapshot, so we do as well. - # Previously, we used a kernel snapshot - but this was found to cause - # extremely strange behaviour at runtime (observed in `flutter precache`), - # where certain functions would not execute properly. dartOutputType = "jit-snapshot"; src = flutterSrc; From e13356db8e5b59467f1d0181e54d6d7fec68ab2a Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 03:03:48 +1100 Subject: [PATCH 11/34] flutter: Disable automatic updates without breaking precache --- .../flutter3/disable-auto-update.patch | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch b/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch index ceaf59b5f535..23a657e7c6a9 100644 --- a/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch +++ b/pkgs/development/compilers/flutter/patches/flutter3/disable-auto-update.patch @@ -11,18 +11,19 @@ index 3532c23114..25dfcae4c7 100644 BIN_NAME="$(basename "$PROG_NAME")" case "$BIN_NAME" in flutter*) -diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart -index 13efbde879..467b3a7cbf 100644 ---- a/packages/flutter_tools/lib/src/cache.dart -+++ b/packages/flutter_tools/lib/src/cache.dart -@@ -664,6 +664,7 @@ class Cache { +diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart +index b7e624b4e2..edfdde118b 100644 +--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart ++++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart +@@ -1554,7 +1554,7 @@ Run 'flutter -h' (or 'flutter -h') for available flutter commands and - /// Update the cache to contain all `requiredArtifacts`. - Future updateAll(Set requiredArtifacts, {bool offline = false}) async { -+ return; - if (!_lockEnabled) { - return; - } + // Populate the cache. We call this before pub get below so that the + // sky_engine package is available in the flutter cache for pub to find. +- if (shouldUpdateCache) { ++ if (false) { + // First always update universal artifacts, as some of these (e.g. + // ios-deploy on macOS) are required to determine `requiredArtifacts`. + final bool offline; 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 5d6d78639f..90a4dfa555 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart From b63ffdda864476ad240359cb8a708dfcd50e399a Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 03:14:20 +1100 Subject: [PATCH 12/34] flutter: Allow adding additional Dart VM options when launching CLI --- pkgs/development/compilers/flutter/flutter.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 6d011b6f45f9..83011ba1a8e4 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -75,9 +75,9 @@ let # Replace them with simple links and wrappers. rm "$out/bin"/{dart,flutter} ln -s "$out/bin/cache/dart-sdk/bin/dart" "$out/bin/dart" - makeWrapper "$out/bin/dart" "$out/bin/flutter" \ + makeShellWrapper "$out/bin/dart" "$out/bin/flutter" \ --set-default FLUTTER_ROOT "$out" \ - --add-flags "--disable-dart-dev $out/bin/cache/flutter_tools.snapshot" + --add-flags "--disable-dart-dev \$NIX_FLUTTER_TOOLS_VM_OPTIONS $out/bin/cache/flutter_tools.snapshot" runHook postInstall ''; From 59493e57eddc0434fd95dac0d5198760fffabe33 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 03:48:32 +1100 Subject: [PATCH 13/34] flutter: Deregister the Pub dependencies artifact There is no need to cache the flutter_tool pub dependencies, as it is built reproducibly with Nix. --- ...deregister-pub-dependencies-artifact.patch | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 pkgs/development/compilers/flutter/patches/flutter3/deregister-pub-dependencies-artifact.patch diff --git a/pkgs/development/compilers/flutter/patches/flutter3/deregister-pub-dependencies-artifact.patch b/pkgs/development/compilers/flutter/patches/flutter3/deregister-pub-dependencies-artifact.patch new file mode 100644 index 000000000000..01e34c6d292c --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/flutter3/deregister-pub-dependencies-artifact.patch @@ -0,0 +1,19 @@ +diff --git a/packages/flutter_tools/lib/src/flutter_cache.dart b/packages/flutter_tools/lib/src/flutter_cache.dart +index 252021cf78..e50ef0885d 100644 +--- a/packages/flutter_tools/lib/src/flutter_cache.dart ++++ b/packages/flutter_tools/lib/src/flutter_cache.dart +@@ -51,14 +51,6 @@ class FlutterCache extends Cache { + registerArtifact(IosUsbArtifacts(artifactName, this, platform: platform)); + } + registerArtifact(FontSubsetArtifacts(this, platform: platform)); +- registerArtifact(PubDependencies( +- logger: logger, +- // flutter root and pub must be lazily initialized to avoid accessing +- // before the version is determined. +- flutterRoot: () => Cache.flutterRoot!, +- pub: () => pub, +- projectFactory: projectFactory, +- )); + } + } + \ No newline at end of file From de1d8091daa2ba4acf33f0872de168aece643b40 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 04:56:32 +1100 Subject: [PATCH 14/34] flutter: Update FLUTTER_ROOT in SDK symlink derivation --- pkgs/development/compilers/flutter/sdk-symlink.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/sdk-symlink.nix b/pkgs/development/compilers/flutter/sdk-symlink.nix index 6fb4f5edc0ee..c4e3cea5d597 100644 --- a/pkgs/development/compilers/flutter/sdk-symlink.nix +++ b/pkgs/development/compilers/flutter/sdk-symlink.nix @@ -1,4 +1,6 @@ -{ symlinkJoin }: flutter: +{ symlinkJoin +, makeWrapper +}: flutter: let self = @@ -6,6 +8,12 @@ let name = "${flutter.name}-sdk-links"; paths = [ flutter flutter.sdk ]; + nativeBuildInputs = [ makeWrapper ]; + postBuild = '' + wrapProgram "$out/bin/flutter" \ + --set-default FLUTTER_ROOT "$out" + ''; + passthru = flutter.passthru // { # Update the SDK attribute. # This allows any modified SDK files to be included From 44030b7f7d692a25d0dfcc5d6a6fead110d3370b Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 05:00:11 +1100 Subject: [PATCH 15/34] flutter: Fetch artifacts with `flutter prefetch` --- .../flutter/artifacts/fetch-artifacts.nix | 43 ++++ .../compilers/flutter/artifacts/hashes.nix | 38 +++ .../flutter/artifacts/overrides/linux.nix | 10 + .../flutter/artifacts/prepare-artifacts.nix | 21 ++ .../development/compilers/flutter/default.nix | 8 +- .../flutter/engine-artifacts/default.nix | 243 ------------------ .../flutter/engine-artifacts/hashes.nix | 118 --------- .../compilers/flutter/sdk-symlink.nix | 2 +- .../development/compilers/flutter/wrapper.nix | 117 +++------ 9 files changed, 152 insertions(+), 448 deletions(-) create mode 100644 pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix create mode 100644 pkgs/development/compilers/flutter/artifacts/hashes.nix create mode 100644 pkgs/development/compilers/flutter/artifacts/overrides/linux.nix create mode 100644 pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix delete mode 100644 pkgs/development/compilers/flutter/engine-artifacts/default.nix delete mode 100644 pkgs/development/compilers/flutter/engine-artifacts/hashes.nix diff --git a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix new file mode 100644 index 000000000000..96e70acf29bc --- /dev/null +++ b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix @@ -0,0 +1,43 @@ +{ lib +, runCommand +, cacert +, unzip + +, platform +, flutter +, hash +}: + +let + platforms = [ + "android" + "ios" + "web" + "linux" + "windows" + "macos" + "fuchsia" + "universal" + ]; +in +runCommand "flutter-artifacts-${platform}" +{ + nativeBuildInputs = [ flutter unzip ]; + + NIX_FLUTTER_TOOLS_VM_OPTIONS = "--root-certs-file=${cacert}/etc/ssl/certs/ca-bundle.crt"; + + outputHash = hash; + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + + passthru = { + inherit platform; + }; +} '' + runHook preBuild + + 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))} + + runHook postBuild +'' diff --git a/pkgs/development/compilers/flutter/artifacts/hashes.nix b/pkgs/development/compilers/flutter/artifacts/hashes.nix new file mode 100644 index 000000000000..8ae74bff17ed --- /dev/null +++ b/pkgs/development/compilers/flutter/artifacts/hashes.nix @@ -0,0 +1,38 @@ +# NOTICE: When updating these hashes, make sure that no additional platforms +# have been added to the `flutter precache` CLI. If any have, they may be +# included in every derivation, unless they are also added to the platform list +# in fetch-artifacts.nix. +# +# The known arguments are as follows: +# $ flutter precache --help --verbose +# Usage: flutter precache [arguments] +# -h, --help Print this usage information. +# -a, --all-platforms Precache artifacts for all host platforms. +# -f, --force Force re-downloading of artifacts. +# --[no-]android Precache artifacts for Android development. +# --[no-]android_gen_snapshot Precache gen_snapshot for Android development. +# --[no-]android_maven Precache Gradle dependencies for Android development. +# --[no-]android_internal_build Precache dependencies for internal Android development. +# --[no-]ios Precache artifacts for iOS development. +# --[no-]web Precache artifacts for web development. +# --[no-]linux Precache artifacts for Linux desktop development. +# --[no-]windows Precache artifacts for Windows desktop development. +# --[no-]macos Precache artifacts for macOS desktop development. +# --[no-]fuchsia Precache artifacts for Fuchsia development. +# --[no-]universal Precache artifacts required for any development platform. +# (defaults to on) +# --[no-]flutter_runner Precache the flutter runner artifacts. +# --[no-]use-unsigned-mac-binaries Precache the unsigned macOS binaries when available. + +{ + "3.13.8" = { + android = "sha256-Uc36aBq8wQo2aEvjAPOoixZElWOE/GNRm2GUfhbwT3Y="; + fuchsia = "sha256-eu0BERdz53CkSexbpu3KA7O6Q4g0s9SGD3t1Snsk3Fk="; + ios = "sha256-QwkeGnutTVsm682CqxRtEd9rKUvN7zlAJcqkvAQYwao="; + linux = "sha256-0gIOwux3YBdmcXgwICr8dpftj1CauaBUX8Rt5GG0WSs="; + macos = "sha256-9WqCJQ37mcGc5tzfqQoY5CqHWHGTizjXf9p73bdnNWc="; + universal = "sha256-wATt1UPjo/fh7RFO1vvcUAdo0dMAaaOUIuzYodsM0v0="; + web = "sha256-DVXJOOFxv7tKt3d0NaYMexkphEcr7+gDFV67I6iAYa0="; + windows = "sha256-s8fJtwQkuZaGXr6vrPiKfpwP/NfewbETwyp9ERGqHYI="; + }; +} diff --git a/pkgs/development/compilers/flutter/artifacts/overrides/linux.nix b/pkgs/development/compilers/flutter/artifacts/overrides/linux.nix new file mode 100644 index 000000000000..bc6114415b90 --- /dev/null +++ b/pkgs/development/compilers/flutter/artifacts/overrides/linux.nix @@ -0,0 +1,10 @@ +{ gtk3 +}: + +{ buildInputs ? [ ] +, ... +}: + +{ + buildInputs = buildInputs ++ [ gtk3 ]; +} diff --git a/pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix b/pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix new file mode 100644 index 000000000000..e248869fdfb2 --- /dev/null +++ b/pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix @@ -0,0 +1,21 @@ +{ stdenv +, lib +, autoPatchelfHook +, src +}: + +stdenv.mkDerivation { + inherit (src) name; + inherit src; + + nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/bin" + cp -r . "$out/bin/cache" + + runHook postInstall + ''; +} diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix index ca405c03a85d..f9c0320edec8 100644 --- a/pkgs/development/compilers/flutter/default.nix +++ b/pkgs/development/compilers/flutter/default.nix @@ -55,13 +55,7 @@ let buildFlutterApplication = callPackage ../../../build-support/flutter { # Package a minimal version of Flutter that only uses Linux desktop release artifacts. flutter = (wrapFlutter (mkCustomFlutter args)).override { - supportsAndroid = false; - includedEngineArtifacts = { - common = [ "flutter_patched_sdk_product" ]; - platform.linux = lib.optionals stdenv.hostPlatform.isLinux - (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64")) - (architecture: [ "release" ])); - }; + supportedTargetPlatforms = [ "universal" "linux" ]; }; }; }; diff --git a/pkgs/development/compilers/flutter/engine-artifacts/default.nix b/pkgs/development/compilers/flutter/engine-artifacts/default.nix deleted file mode 100644 index 30c293c8d75d..000000000000 --- a/pkgs/development/compilers/flutter/engine-artifacts/default.nix +++ /dev/null @@ -1,243 +0,0 @@ -{ lib -, stdenv -, hostPlatform -, engineVersion -, fetchurl -, fetchzip -, autoPatchelfHook -, gtk3 -, flutterVersion -, unzip -, stdenvNoCC -}: - -let - hashes = (import ./hashes.nix).${engineVersion} or - (throw "There are no known artifact hashes for Flutter engine version ${engineVersion}."); - noticeText = stdenvNoCC.mkDerivation (finalAttrs: { - pname = "flutter-notice"; - version = engineVersion; - dontUnpack = true; - src = fetchurl { - pname = "flutter-sky_engine-LICENSE"; - version = engineVersion; - url = "https://raw.githubusercontent.com/flutter/engine/${engineVersion}/sky/packages/sky_engine/LICENSE"; - sha256 = hashes.skyNotice; - }; - flutterNotice = fetchurl { - pname = "flutter-LICENSE"; - version = engineVersion; - url = "https://raw.githubusercontent.com/flutter/flutter/${flutterVersion}/LICENSE"; - sha256 = hashes.flutterNotice; - }; - installPhase = - '' - SRC_TEXT="$(cat $src)" - FLUTTER_NOTICE_TEXT="$(cat $flutterNotice)" - cat << EOF > $out - This artifact is from the Flutter SDK's engine. - This file carries third-party notices for its dependencies. - See also other files, that have LICENSE in the name, in the artifact directory. - - Appendix 1/2: merged sky_engine LICENSE file (also found at ${finalAttrs.src.url}) - $SRC_TEXT - - Appendix 2/2: Flutter license (also found at ${finalAttrs.flutterNotice.url}) - $FLUTTER_NOTICE_TEXT - EOF - ''; - }); - artifacts = - { - common = { - flutter_patched_sdk = { archive = "flutter_patched_sdk.zip"; }; - flutter_patched_sdk_product = { archive = "flutter_patched_sdk_product.zip"; }; - }; - platform = { - android = - (lib.genAttrs - [ "arm" "arm64" "x64" ] - (arch: - { - base = [ - { archive = "artifacts.zip"; } - ]; - variants = lib.genAttrs [ "profile" "release" ] - (variant: [ - { archive = "artifacts.zip"; } - { subdirectory = true; archive = "${lib.toLower hostPlatform.uname.system}-x64.zip"; } - ]); - })) // - { - "x86" = { - base = [ - { archive = "artifacts.zip"; } - ]; - variants.jit-release = [ - { archive = "artifacts.zip"; } - ]; - }; - }; - - darwin = { - "arm64" = { - base = [ - { archive = "artifacts.zip"; } - { archive = "font-subset.zip"; } - ]; - variants = lib.genAttrs [ "profile" "release" ] - (variant: [ - { archive = "artifacts.zip"; } - ]); - }; - "x64" = { - base = [ - { archive = "FlutterEmbedder.framework.zip"; } - { archive = "FlutterMacOS.framework.zip"; } - { archive = "artifacts.zip"; } - { archive = "font-subset.zip"; } - { archive = "gen_snapshot.zip"; } - ]; - variants.profile = [ - { archive = "FlutterMacOS.framework.zip"; } - { archive = "artifacts.zip"; } - { archive = "gen_snapshot.zip"; } - ]; - variants.release = [ - { archive = "FlutterMacOS.dSYM.zip"; } - { archive = "FlutterMacOS.framework.zip"; } - { archive = "artifacts.zip"; } - { archive = "gen_snapshot.zip"; } - ]; - }; - }; - - ios = - (lib.genAttrs - [ "" ] - (arch: - { - base = [ - { archive = "artifacts.zip"; } - ]; - variants.profile = [ - { archive = "artifacts.zip"; } - ]; - variants.release = [ - { archive = "artifacts.zip"; } - { archive = "Flutter.dSYM.zip"; } - ]; - })); - - linux = lib.genAttrs - [ "arm64" "x64" ] - (arch: - let - linux-flutter-gtk = { - archive = "linux-${arch}-flutter-gtk.zip"; - buildInputs = [ gtk3 ]; - }; - in - { - base = [ - ({ archive = "artifacts.zip"; } // lib.optionalAttrs (arch == "arm64") { - # For some reason, the arm64 artifacts are missing shader code in Flutter < 3.10.0. - postPatch = '' - if [ ! -d shader_lib ]; then - ln -s ${lib.findSingle - (pkg: lib.getName pkg == "flutter-artifact-linux-x64-artifacts") - (throw "Could not find the x64 artifact archive.") - (throw "Could not find the correct x64 artifact archive.") - artifactDerivations.platform.linux.x64.base - }/shader_lib . - fi - ''; - }) - { archive = "font-subset.zip"; } - (linux-flutter-gtk // { - # https://github.com/flutter/flutter/commit/9d94a51b607600a39c14470c35c676eb3e30eed6 - variant = "debug"; - }) - ]; - variants = lib.genAttrs [ "debug" "profile" "release" ] (variant: [ - linux-flutter-gtk - ]); - }); - }; - }; - - mkArtifactDerivation = { platform ? null, variant ? null, subdirectory ? null, archive, ... }@args: - let - artifactDirectory = if platform == null then null else "${platform}${lib.optionalString (variant != null) "-${variant}"}"; - archiveBasename = lib.removeSuffix ".${(lib.last (lib.splitString "." archive))}" archive; - overrideUnpackCmd = builtins.elem archive [ "FlutterEmbedder.framework.zip" "FlutterMacOS.framework.zip" ]; - in - stdenv.mkDerivation ({ - pname = "flutter-artifact${lib.optionalString (platform != null) "-${artifactDirectory}"}-${archiveBasename}"; - version = engineVersion; - - nativeBuildInputs = [ unzip ] - ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]; - - src = - if overrideUnpackCmd then - (fetchurl { - url = "https://storage.googleapis.com/flutter_infra_release/flutter/${engineVersion}${lib.optionalString (platform != null) "/${artifactDirectory}"}/${archive}"; - hash = (if artifactDirectory == null then hashes else hashes.${artifactDirectory}).${archive}; - }) else - (fetchzip { - url = "https://storage.googleapis.com/flutter_infra_release/flutter/${engineVersion}${lib.optionalString (platform != null) "/${artifactDirectory}"}/${archive}"; - stripRoot = false; - hash = (if artifactDirectory == null then hashes else hashes.${artifactDirectory}).${archive}; - }); - - sourceRoot = if overrideUnpackCmd then "." else null; - unpackCmd = if overrideUnpackCmd then "unzip -o $src -d $out" else null; - - installPhase = - let - destination = "$out/${if subdirectory == true then archiveBasename else if subdirectory != null then subdirectory else "."}"; - in - '' - # ship the notice near all artifacts. if the artifact directory is / multiple directories are nested in $src, link it there. If there isn't a directory, link it in root - # this *isn't the same as the subdirectory variable above* - DIR_CNT="$(echo */ | wc -w)" - if [[ "$DIR_CNT" == 0 ]]; then - ln -s ${noticeText} LICENSE.README - else - for dir in */ - do - ln -s ${noticeText} "$dir/LICENSE.README" - done - fi - mkdir -p "${destination}" - cp -r . "${destination}" - ''; - } // args); - - artifactDerivations = { - common = builtins.mapAttrs (name: mkArtifactDerivation) artifacts.common; - platform = - builtins.mapAttrs - (os: architectures: - builtins.mapAttrs - (architecture: variants: { - base = map - (args: mkArtifactDerivation ({ - platform = "${os}${lib.optionalString (architecture != "") "-${architecture}"}"; - } // args)) - variants.base; - variants = builtins.mapAttrs - (variant: variantArtifacts: map - (args: mkArtifactDerivation ({ - platform = "${os}${lib.optionalString (architecture != "") "-${architecture}"}"; - inherit variant; - } // args)) - variantArtifacts) - variants.variants; - }) - architectures) - artifacts.platform; - }; -in -artifactDerivations diff --git a/pkgs/development/compilers/flutter/engine-artifacts/hashes.nix b/pkgs/development/compilers/flutter/engine-artifacts/hashes.nix deleted file mode 100644 index 7bfb60d7a9ac..000000000000 --- a/pkgs/development/compilers/flutter/engine-artifacts/hashes.nix +++ /dev/null @@ -1,118 +0,0 @@ -{ - "767d8c75e898091b925519803830fc2721658d07" = { - skyNotice = "sha256-bJMktK26wC9fVzdhLNcTHqOg5sHRZ535LB5u5dgwjlY="; - flutterNotice = "sha256-pZjblLYpD/vhC17PkRBXtqlDNRxyf92p5fKJHWhwCiA="; - android-arm = { - "artifacts.zip" = "sha256-pnUDY2sUN2r/LrivyNkfTUpQC90GKOI6Ya+0lgIz+c0="; - }; - android-arm-profile = { - "artifacts.zip" = "sha256-/kDNI+no4u2Ri/FqqsQEp2iEqifULYGqzz8w0G4pzCM="; - "linux-x64.zip" = "sha256-fUfaDJIo1VcdJHcd0jO98Az3OdNQ+JtA5Mp6nQVVU4E="; - "darwin-x64.zip" = "sha256-J7vDD5VEsgnWmbI8acM3vQwrnrqcfMaCijiItDfniLY="; - }; - android-arm-release = { - "artifacts.zip" = "sha256-tVAFHHG8A8vlgQu6l6ybdfm6OmBf2vrYf3PZByWvs08="; - "linux-x64.zip" = "sha256-lrejG7zpUBox9kPvs1uPM/lyR1d/SAc1w+c6kcqghHI="; - "darwin-x64.zip" = "sha256-8lKOsqLgbnuoCR87v84dn8V3PRzl1+maWFIHopiGvbc="; - }; - android-arm64 = { - "artifacts.zip" = "sha256-rcU2mX0nP1ot+6DU+uxvILUOAuwTPGH23UQ6riBs0d4="; - }; - android-arm64-profile = { - "artifacts.zip" = "sha256-x4TEJWi3c6mEPGh+3l4PtRqsg4Tq7mxHtGz+4MqwzPw="; - "linux-x64.zip" = "sha256-PsDKOq3DXaNeNtaFtDQJ9JIEESXBHm8XHHpOw2u1cGg="; - "darwin-x64.zip" = "sha256-K4W1CEBOlZVsHjuhvKCUZWv45VSohRd23vviaLqMNjQ="; - }; - android-arm64-release = { - "artifacts.zip" = "sha256-w+J4sNhYoj44IiHpZ0BkemCYlE9wOTvWL57Y8RCstkI="; - "linux-x64.zip" = "sha256-MJsmck27V14/f0IAT6b/R47p8/eCMX9Nn//PEAbEeOY="; - "darwin-x64.zip" = "sha256-xXa5GFatJPiwBANqeWUpAdM9gibD4xH85aI6YpJrcpI="; - }; - android-x64 = { - "artifacts.zip" = "sha256-doNUwEJkwncHPIf2c8xOZByUU8dmogtWlc6q7n7ElDY="; - }; - android-x64-profile = { - "artifacts.zip" = "sha256-N3AjdHdzj4s6v3f3Gf6n/1Xk0W7xFQP70SneCNlj2sk="; - "linux-x64.zip" = "sha256-pNn75iZqLwOGO3ZmymmrSasDPMmDWwp9ZWBv9Xti4cU="; - "darwin-x64.zip" = "sha256-6O4lA/4wZ91ODUUYHe4HpjvraAEbhHiehBmf3sT37Dc="; - }; - android-x64-release = { - "artifacts.zip" = "sha256-odDS/m8fgSA24EYt+W2sEDmOlPO17FZxxomWuYUHmns="; - "linux-x64.zip" = "sha256-sVQYmu0KaPADlL59XZc26Ks+TbmaJxRGPiJKlWxUhRA="; - "darwin-x64.zip" = "sha256-dep/CmBIDkvqYKQPWMCDTDbFhVvOk6N7JAF8v3dr/P8="; - }; - android-x86 = { - "artifacts.zip" = "sha256-MzTFQ0XPtd9OXvKfM98bwpxN/xfEcXox24gn/4aS/Do="; - }; - android-x86-jit-release = { - "artifacts.zip" = "sha256-cUsBqJxOOluwnYEFzdtZof8c4Vp1D81HkEEH8aRGLyY="; - }; - darwin-arm64 = { - "artifacts.zip" = "sha256-df+rmN0RqLM7MgEKjTcybMY0bFYCB1jsTvaVE1J0BzY="; - "font-subset.zip" = "sha256-hJ5fECxN4oZX6E9ivzSDGejNSj56t2SKccbyfozXxps="; - }; - darwin-arm64-profile = { - "artifacts.zip" = "sha256-EaXOr998zE4cG5G5FRtsDGt3jjg1GjkRGE/ZDD3Coto="; - }; - darwin-arm64-release = { - "artifacts.zip" = "sha256-1XMoM8jDRoUSPMauKD5lsgC25B7Htod8wYouDKSEGJY="; - }; - darwin-x64 = { - "FlutterEmbedder.framework.zip" = "sha256-vzvt0pwo1HbIxxym/jn2Y+1+Iqm/Gw2TfymEcuUHIXQ="; - "FlutterMacOS.framework.zip" = "sha256-cMTCULaVOKDq8VrqCmZLo0IPBve0GSh0K2yvtdCvX8c="; - "artifacts.zip" = "sha256-8BViZUz4b0XurQJM+FCU2toONKmhajabCc66gBUVGgY="; - "font-subset.zip" = "sha256-VgqNdUmvTbSedQtJNT+Eq90GWS4hXCDCBDBjno6s1dk="; - "gen_snapshot.zip" = "sha256-4O0ZfKt96x8/Jwh8DgBoPFiv84Tqf9tR/f0PVRJlJiQ="; - }; - darwin-x64-profile = { - "FlutterMacOS.framework.zip" = "sha256-IrXK0Mjllic3OKaYKKpAE9gPIceTO32hGqgxGR66QmY="; - "artifacts.zip" = "sha256-IHllbxwRMrEWA1MI0DRCYYRzYAdQIL8B9b5rZHsOvjc="; - "gen_snapshot.zip" = "sha256-bPI6pHrWQR1X7CzytbJA90TYe3cg1yN+9v7JtsCCrbQ="; - }; - darwin-x64-release = { - "FlutterMacOS.dSYM.zip" = "sha256-HjU8sLPwvOwO3LP7krpZZW6/t3sN3rX2frFnBp1Kk0I="; - "FlutterMacOS.framework.zip" = "sha256-GuTWojZFdSEeOiSYxH8XGSWsxcrkUpnXA61B0NpDa5A="; - "artifacts.zip" = "sha256-tQCm1HHrhffNz9a0lNIHXLBqFMbT4QiaibKvRKuuhJ4="; - "gen_snapshot.zip" = "sha256-0na+yx0Nxe/FuHVZqhgbRniZLInShoKE3USaJg0829o="; - }; - "flutter_patched_sdk.zip" = "sha256-AVjXLND3nJAaGyBAhytBRUvbkJtwZEcndQSrq+D2c08="; - "flutter_patched_sdk_product.zip" = "sha256-31qgieDI897sXtEf8ok2SdFgrlN57bwhT3FUfdofZi0="; - ios = { - "artifacts.zip" = "sha256-RicBTTBX5aIQwfcolDrKe0MVG9uTp56RYMWgR75AVEw="; - }; - ios-profile = { - "artifacts.zip" = "sha256-6EXHvy36K+rRGpjt0GL/DyuOhpAGeaOrZAZvPZuLyys="; - }; - ios-release = { - "Flutter.dSYM.zip" = "sha256-zYqlX4QhxnDb9LasMcBcPO/+30LCfVbwC+z+wZiiEqk="; - "artifacts.zip" = "sha256-DVpynf2LxU6CPC1BPQbi8OStcIwJKX55rDSWNiJ4KNk="; - }; - linux-arm64 = { - "artifacts.zip" = "sha256-djesma+IqQZgGlxQj4Gv6hAkQhQKQp7Gsa1I4hksqNc="; - "font-subset.zip" = "sha256-Wo11dks0uhLI2nu+9QJ7aLmvfsPcuqvcmquak4qv5XM="; - }; - linux-arm64-debug = { - "linux-arm64-flutter-gtk.zip" = "sha256-6T2Ycxe3GTVnFGfBFfXLZwPklIndQ6hojnCSnMeXJso="; - }; - linux-arm64-profile = { - "linux-arm64-flutter-gtk.zip" = "sha256-ycInFHuRu7r+50GsoFR4v/rIRiAQaQ9zFemd2d9AnpQ="; - }; - linux-arm64-release = { - "linux-arm64-flutter-gtk.zip" = "sha256-J60MU8pHDVL9DyX5A3YdCRkKXnTgvALhHiEzYiPSSuA="; - }; - linux-x64 = { - "artifacts.zip" = "sha256-ZUMRJ0dzaeRQUYy5S7gDLWa3w9CVhNPORN9l+lwxAMs="; - "font-subset.zip" = "sha256-pmtHAgIj5tXzUsDrrxB5JwfLDNzMCqouUCOyYN5BOEQ="; - }; - linux-x64-debug = { - "linux-x64-flutter-gtk.zip" = "sha256-otmghZAiUlpLYfFaWd18UWlfctKcYsMRBMP78ZyBj/E="; - }; - linux-x64-profile = { - "linux-x64-flutter-gtk.zip" = "sha256-bT6xMYlwTB9JOV1790cJqTSEXYstdI4sZCQzFzcpa5s="; - }; - linux-x64-release = { - "linux-x64-flutter-gtk.zip" = "sha256-E8Eogr0nD7yaxjuoNhpvF4tTx9N53y3iOkI71Eqx5Ko="; - }; - }; -} - diff --git a/pkgs/development/compilers/flutter/sdk-symlink.nix b/pkgs/development/compilers/flutter/sdk-symlink.nix index c4e3cea5d597..c56a15dee462 100644 --- a/pkgs/development/compilers/flutter/sdk-symlink.nix +++ b/pkgs/development/compilers/flutter/sdk-symlink.nix @@ -6,7 +6,7 @@ let self = symlinkJoin { name = "${flutter.name}-sdk-links"; - paths = [ flutter flutter.sdk ]; + paths = [ flutter flutter.cacheDir flutter.sdk ]; nativeBuildInputs = [ makeWrapper ]; postBuild = '' diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index fd08c324ba3a..5d8f21629f9e 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -3,27 +3,14 @@ , darwin , callPackage , flutter -, supportsLinuxDesktop ? stdenv.hostPlatform.isLinux -, supportsAndroid ? (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isDarwin) -, supportsDarwin ? stdenv.hostPlatform.isDarwin -, supportsIOS ? stdenv.hostPlatform.isDarwin -, includedEngineArtifacts ? { - common = [ - "flutter_patched_sdk" - "flutter_patched_sdk_product" - ]; - platform = { - android = lib.optionalAttrs supportsAndroid - ((lib.genAttrs [ "arm" "arm64" "x64" ] (architecture: [ "profile" "release" ])) // { x86 = [ "jit-release" ]; }); - darwin = lib.optionalAttrs supportsDarwin - ((lib.genAttrs [ "arm64" "x64" ] (architecture: [ "profile" "release" ]))); - ios = lib.optionalAttrs supportsIOS - ((lib.genAttrs [ "" ] (architecture: [ "profile" "release" ]))); - linux = lib.optionalAttrs supportsLinuxDesktop - (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64")) - (architecture: [ "debug" "profile" "release" ])); - }; - } +, supportedTargetPlatforms ? [ + "universal" + "web" + ] + ++ lib.optional stdenv.hostPlatform.isLinux "linux" + ++ lib.optional (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isDarwin) "android" + ++ lib.optionals stdenv.hostPlatform.isDarwin [ "macos" "ios" ] +, artifactHashes ? (import ./artifacts/hashes.nix).${flutter.version} , extraPkgConfigPackages ? [ ] , extraLibraries ? [ ] , extraIncludes ? [ ] @@ -57,61 +44,33 @@ }: let - engineArtifacts = callPackage ./engine-artifacts { - inherit (flutter) engineVersion; - flutterVersion = flutter.version; - }; - mkCommonArtifactLinkCommand = { artifact }: - '' - mkdir -p $out/artifacts/engine/common - lndir -silent ${artifact} $out/artifacts/engine/common - ''; - mkPlatformArtifactLinkCommand = { artifact, os, architecture, variant ? null }: - let - artifactDirectory = "${os}-${architecture}${lib.optionalString (variant != null) "-${variant}"}"; - in - '' - mkdir -p $out/artifacts/engine/${artifactDirectory} - lndir -silent ${artifact} $out/artifacts/engine/${artifactDirectory} - ''; - engineArtifactDirectory = - runCommandLocal "flutter-engine-artifacts-${flutter.version}" { nativeBuildInputs = [ lndir ]; } - ( - builtins.concatStringsSep "\n" - ((map - (name: mkCommonArtifactLinkCommand { - artifact = engineArtifacts.common.${name}; - }) - (includedEngineArtifacts.common or [ ])) ++ - (builtins.foldl' - (commands: os: commands ++ - (builtins.foldl' - (commands: architecture: commands ++ - (builtins.foldl' - (commands: variant: commands ++ - (map - (artifact: mkPlatformArtifactLinkCommand { - inherit artifact os architecture variant; - }) - engineArtifacts.platform.${os}.${architecture}.variants.${variant})) - (map - (artifact: mkPlatformArtifactLinkCommand { - inherit artifact os architecture; - }) - engineArtifacts.platform.${os}.${architecture}.base) - includedEngineArtifacts.platform.${os}.${architecture})) - [ ] - (builtins.attrNames includedEngineArtifacts.platform.${os}))) - [ ] - (builtins.attrNames (includedEngineArtifacts.platform or { })))) - ); + supportsLinuxDesktopTarget = builtins.elem "linux" supportedTargetPlatforms; + + mkPlatformArtifacts = platform: + (callPackage ./artifacts/prepare-artifacts.nix { + src = callPackage ./artifacts/fetch-artifacts.nix { + inherit platform; + # Use a version of Flutter with just enough capabilities to download + # artifacts. + flutter = callPackage ./wrapper.nix { + inherit flutter; + supportedTargetPlatforms = [ ]; + }; + hash = artifactHashes.${platform} or ""; + }; + }).overrideAttrs ( + if builtins.pathExists ./artifacts/overrides/${platform}.nix + then callPackage ./artifacts/overrides/${platform}.nix { } + else ({ ... }: { }) + ); cacheDir = symlinkJoin { name = "flutter-cache-dir"; - paths = [ - engineArtifactDirectory - "${flutter}/bin/cache" - ]; + paths = map mkPlatformArtifacts supportedTargetPlatforms; + postBuild = '' + mkdir -p "$out/bin/cache" + ln -s '${flutter}/bin/cache/dart-sdk' "$out/bin/cache" + ''; }; # By default, Flutter stores downloaded files (such as the Pub cache) in the SDK directory. @@ -120,7 +79,7 @@ let # 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}'} + export FLUTTER_CACHE_DIR=''${FLUTTER_CACHE_DIR:-'${cacheDir}/bin/cache'} ${flutter}/bin/flutter "$@" ''; @@ -128,7 +87,7 @@ let tools = [ git which ]; # Libraries that Flutter apps depend on at runtime. - appRuntimeDeps = lib.optionals supportsLinuxDesktop [ + appRuntimeDeps = lib.optionals supportsLinuxDesktopTarget [ atk cairo gdk-pixbuf @@ -152,10 +111,10 @@ let # Some header files and libraries are not properly located by the Flutter SDK. # They must be manually included. - appStaticBuildDeps = (lib.optionals supportsLinuxDesktop [ libX11 xorgproto zlib ]) ++ extraLibraries; + appStaticBuildDeps = (lib.optionals supportsLinuxDesktopTarget [ libX11 xorgproto zlib ]) ++ extraLibraries; # Tools used by the Flutter SDK to compile applications. - buildTools = lib.optionals supportsLinuxDesktop [ + buildTools = lib.optionals supportsLinuxDesktopTarget [ pkg-config cmake ninja @@ -174,12 +133,12 @@ in nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ] - ++ lib.optionals supportsLinuxDesktop [ glib wrapGAppsHook ]; + ++ lib.optionals supportsLinuxDesktopTarget [ glib wrapGAppsHook ]; passthru = flutter.passthru // { inherit (flutter) version; unwrapped = flutter; - inherit engineArtifacts; + inherit cacheDir; }; dontUnpack = true; From b6a3ff83e197f821018e273a02e8062a867998a7 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 05:11:31 +1100 Subject: [PATCH 16/34] flutter: Propagate .git in SDK symlink derivation --- pkgs/development/compilers/flutter/sdk-symlink.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/compilers/flutter/sdk-symlink.nix b/pkgs/development/compilers/flutter/sdk-symlink.nix index c56a15dee462..044a508805f5 100644 --- a/pkgs/development/compilers/flutter/sdk-symlink.nix +++ b/pkgs/development/compilers/flutter/sdk-symlink.nix @@ -12,6 +12,11 @@ let postBuild = '' wrapProgram "$out/bin/flutter" \ --set-default FLUTTER_ROOT "$out" + + # symlinkJoin seems to be missing the .git directory for some reason. + if [ -d '${flutter.sdk}/.git' ]; then + ln -s '${flutter.sdk}/.git' "$out" + fi ''; passthru = flutter.passthru // { From 98e4fb2d0719f21413ae8f3e71814ec543bdd892 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 05:28:42 +1100 Subject: [PATCH 17/34] flutter: Pass pubGetScript through to buildDartApplication --- pkgs/build-support/flutter/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix index 3e136211655b..bcee31506df1 100644 --- a/pkgs/build-support/flutter/default.nix +++ b/pkgs/build-support/flutter/default.nix @@ -48,6 +48,8 @@ flutter config --enable-linux-desktop >/dev/null ''; + inherit pubGetScript; + nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ wrapGAppsHook ]; buildInputs = (args.buildInputs or [ ]) ++ [ glib ]; From d331e2d68c1353cdaab0a4671691eb23a68d5530 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 05:29:59 +1100 Subject: [PATCH 18/34] fetchDartDeps: Use given setup and Pub get script in dependency list derivation --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index 51052cae18f4..27b5e1f1b20d 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -160,7 +160,14 @@ let configurePhase = '' runHook preConfigure - doPubGet dart pub get --offline + + ${sdkSetupScript} + + _pub_get() { + ${pubGetScript} --offline + } + doPubGet _pub_get + runHook postConfigure ''; From 75b809c7c6b0232bf4dd311872a6f69defa1c32b Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 05:31:25 +1100 Subject: [PATCH 19/34] buildDartApplication: Add entire Dart derivation to nativeBuildInputs --- .../dart/build-dart-application/default.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkgs/build-support/dart/build-dart-application/default.nix b/pkgs/build-support/dart/build-dart-application/default.nix index 1a98f98fb8e6..2cb193ac6f16 100644 --- a/pkgs/build-support/dart/build-dart-application/default.nix +++ b/pkgs/build-support/dart/build-dart-application/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, callPackage, fetchDartDeps, writeText, symlinkJoin, dartHooks, makeWrapper, dart, cacert, nodejs, darwin, jq }: +{ lib, stdenv, callPackage, fetchDartDeps, runCommand, symlinkJoin, writeText, dartHooks, makeWrapper, dart, cacert, nodejs, darwin, jq }: { sdkSetupScript ? "" , pubGetScript ? "dart pub get" @@ -37,13 +37,15 @@ let dartDeps = (fetchDartDeps.override { dart = symlinkJoin { - name = "dart-fod"; - paths = [ dart ]; - nativeBuildInputs = [ makeWrapper ]; - postBuild = '' - wrapProgram "$out/bin/dart" \ - --add-flags "--root-certs-file=${cacert}/etc/ssl/certs/ca-bundle.crt" - ''; + name = "dart-sdk-fod"; + paths = [ + (runCommand "dart-fod" { nativeBuildInputs = [ makeWrapper ]; } '' + mkdir -p "$out/bin" + makeWrapper "${dart}/bin/dart" "$out/bin/dart" \ + --add-flags "--root-certs-file=${cacert}/etc/ssl/certs/ca-bundle.crt" + '') + dart + ]; }; }) { buildDrvArgs = args; From 623ac19416c470a71b28da15b1b37403b2d28501 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 15:40:16 +1100 Subject: [PATCH 20/34] fetchDartDeps: Generalise dependency derivation logic --- .../dart/fetch-dart-deps/default.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index 27b5e1f1b20d..4f32365f857f 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -154,11 +154,10 @@ let outputHash = if vendorHash != "" then vendorHash else lib.fakeSha256; } // (removeAttrs drvArgs [ "name" "pname" ])); - depsListDrv = stdenvNoCC.mkDerivation ({ - name = "${name}-dart-deps-list.json"; - nativeBuildInputs = [ hook dart jq ]; + mkDepsDrv = args: stdenvNoCC.mkDerivation (args // { + nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [ hook dart ]; - configurePhase = '' + configurePhase = args.configurePhase or '' runHook preConfigure ${sdkSetupScript} @@ -170,6 +169,12 @@ let runHook postConfigure ''; + } // (removeAttrs buildDrvInheritArgs [ "name" "pname" ])); + + depsListDrv = mkDepsDrv { + name = "${name}-dart-deps-list.json"; + + nativeBuildInputs = [ jq ]; buildPhase = '' runHook preBuild @@ -178,7 +183,7 @@ let ''; dontInstall = true; - } // (removeAttrs buildDrvInheritArgs [ "name" "pname" ])); + }; # As of Dart 3.0.0, Pub checks the revision of cached Git-sourced packages. # Git must be wrapped to return a positive result, as the real .git directory is wiped From e99f59010ce621520e6bdbb092f547f143fbd254 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 15:40:54 +1100 Subject: [PATCH 21/34] fetchDartDeps: Pass through the dependency cache --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index 4f32365f857f..fd3594df9950 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -207,6 +207,7 @@ let substitutions = { inherit gitSourceWrapper deps; }; propagatedBuildInputs = [ dart git ]; passthru = { + inherit deps; files = deps.outPath; depsListFile = depsListDrv.outPath; }; From 0d82a3864a86eb12cb6fdf38914014f47c260ab5 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 15:43:01 +1100 Subject: [PATCH 22/34] fetchDartDeps: Add a package_config.json derivation --- .../dart/fetch-dart-deps/default.nix | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index fd3594df9950..66050f9fdf35 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -185,6 +185,33 @@ let dontInstall = true; }; + packageConfigDrv = mkDepsDrv { + name = "${name}-package-config.json"; + + nativeBuildInputs = [ jq ]; + + buildPhase = '' + runHook preBuild + + # Canonicalise the package_config.json, and replace references to the + # reconstructed package cache with the original FOD. + # + # The reconstructed package cache is not reproducible. The intended + # use-case of this derivation is for use with tools that use a + # package_config.json to load assets from packages, and not for use with + # Pub directly, which requires the setup performed by the hook before + # usage. + jq -S ' + .packages[] |= . + { rootUri: .rootUri | gsub("'"$PUB_CACHE"'"; "${hook.deps}/cache/.pub-cache") } + | .generated |= "1970-01-01T00:00:00Z" + ' .dart_tool/package_config.json > $out + + runHook postBuild + ''; + + dontInstall = true; + }; + # As of Dart 3.0.0, Pub checks the revision of cached Git-sourced packages. # Git must be wrapped to return a positive result, as the real .git directory is wiped # to produce a deteministic dependency derivation output. @@ -210,6 +237,7 @@ let inherit deps; files = deps.outPath; depsListFile = depsListDrv.outPath; + packageConfig = packageConfigDrv; }; }) ./setup-hook.sh; in From ef3625ff565e62fe618804e86716f65ba14e26df Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 15:47:28 +1100 Subject: [PATCH 23/34] flutter: Link in the fluter_tools package_config.json --- pkgs/development/compilers/flutter/flutter.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 83011ba1a8e4..befff3516b89 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -57,8 +57,18 @@ let fi mkdir -p bin/cache + + # Add a flutter_tools artifact stamp, and build a snapshot. + # This is the Flutter CLI application. echo "$(git rev-parse HEAD)" > bin/cache/flutter_tools.stamp ln -s '${tools}/share/flutter_tools.snapshot' bin/cache/flutter_tools.snapshot + + # Some of flutter_tools's dependencies contain static assets. The + # application attempts to read its own package_config.json to find these + # assets at runtime. + mkdir -p packages/flutter_tools/.dart_tool + ln -s '${tools.dartDeps.packageConfig}' packages/flutter_tools/.dart_tool/package_config.json + echo -n "${version}" > version ''; From 17a034deaf62ad70fc7b4744dcbdd02610c63893 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 20:09:08 +1100 Subject: [PATCH 24/34] flutter: Add platform artifact derivations to cacheDir passthru --- pkgs/development/compilers/flutter/wrapper.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 5d8f21629f9e..2da1140889ee 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -46,7 +46,7 @@ let supportsLinuxDesktopTarget = builtins.elem "linux" supportedTargetPlatforms; - mkPlatformArtifacts = platform: + platformArtifacts = lib.genAttrs supportedTargetPlatforms (platform: (callPackage ./artifacts/prepare-artifacts.nix { src = callPackage ./artifacts/fetch-artifacts.nix { inherit platform; @@ -62,15 +62,16 @@ let if builtins.pathExists ./artifacts/overrides/${platform}.nix then callPackage ./artifacts/overrides/${platform}.nix { } else ({ ... }: { }) - ); + )); - cacheDir = symlinkJoin { + cacheDir = symlinkJoin rec { name = "flutter-cache-dir"; - paths = map mkPlatformArtifacts supportedTargetPlatforms; + paths = builtins.attrValues platformArtifacts; postBuild = '' mkdir -p "$out/bin/cache" ln -s '${flutter}/bin/cache/dart-sdk' "$out/bin/cache" ''; + passthru.platform = platformArtifacts; }; # By default, Flutter stores downloaded files (such as the Pub cache) in the SDK directory. From c524427335774e952acd9af74bd84b6ee9267304 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 20:51:37 +1100 Subject: [PATCH 25/34] flutter: Set host platform at compilation The Flutter CLI normally detects the host platform at runtime, but this results in incorrect behaviour in the Nix build environment. --- .../compilers/flutter/flutter-tools.nix | 8 ++++--- .../flutter3/override-host-platform.patch | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/compilers/flutter/patches/flutter3/override-host-platform.patch diff --git a/pkgs/development/compilers/flutter/flutter-tools.nix b/pkgs/development/compilers/flutter/flutter-tools.nix index bf673400b765..0aedd174e2ed 100644 --- a/pkgs/development/compilers/flutter/flutter-tools.nix +++ b/pkgs/development/compilers/flutter/flutter-tools.nix @@ -1,4 +1,5 @@ -{ buildDartApplication +{ hostPlatform +, buildDartApplication , git , which , dart @@ -24,8 +25,6 @@ buildDartApplication.override { inherit dart; } rec { prePatch = ''pushd "$NIX_BUILD_TOP/source"''; postPatch = ''popd''; - dartEntryPoints."flutter_tools.snapshot" = "bin/flutter_tools.dart"; - # When the JIT snapshot is being built, the application needs to run. # It attempts to generate configuration files, and relies on a few external # tools. @@ -37,6 +36,9 @@ buildDartApplication.override { inherit dart; } rec { ln -s '${dart}' "$FLUTTER_ROOT/bin/cache/dart-sdk" ''; + dartEntryPoints."flutter_tools.snapshot" = "bin/flutter_tools.dart"; + dartCompileFlags = [ "--define=NIX_FLUTTER_HOST_PLATFORM=${hostPlatform.system}" ]; + # The Dart wrapper launchers are useless for the Flutter tool - it is designed # to be launched from a snapshot by the SDK. postInstall = '' diff --git a/pkgs/development/compilers/flutter/patches/flutter3/override-host-platform.patch b/pkgs/development/compilers/flutter/patches/flutter3/override-host-platform.patch new file mode 100644 index 000000000000..51dcfdb5cc57 --- /dev/null +++ b/pkgs/development/compilers/flutter/patches/flutter3/override-host-platform.patch @@ -0,0 +1,21 @@ +diff --git a/packages/flutter_tools/lib/src/base/os.dart b/packages/flutter_tools/lib/src/base/os.dart +index 1ce1951cef..1bd7602318 100644 +--- a/packages/flutter_tools/lib/src/base/os.dart ++++ b/packages/flutter_tools/lib/src/base/os.dart +@@ -260,7 +260,15 @@ class _PosixUtils extends OperatingSystemUtils { + @override + String get pathVarSeparator => ':'; + +- HostPlatform? _hostPlatform; ++ // uname outputs build platform characteristics, not host platform characteristics. ++ // _MacOSUtils uses sysctl instead, which is still incorrect. ++ HostPlatform? _hostPlatform = switch (const String.fromEnvironment('NIX_FLUTTER_HOST_PLATFORM')) { ++ 'x86_64-linux' => HostPlatform.linux_x64, ++ 'aarch64-linux' => HostPlatform.linux_arm64, ++ 'x86_64-darwin' => HostPlatform.darwin_x64, ++ 'arm64-darwin' => HostPlatform.darwin_arm64, ++ String value => throw ArgumentError.value(value, 'NIX_FLUTTER_HOST_PLATFORM', 'Unknown Nix host platform!'), ++ }; + + @override + HostPlatform get hostPlatform { From c969311bc58e5a62b7bf6e334ded06cfbfdce948 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 22:21:08 +1100 Subject: [PATCH 26/34] flutter: Add artifact hashes for all platforms --- .../compilers/flutter/artifacts/hashes.nix | 53 ++++++++++++++++--- .../development/compilers/flutter/wrapper.nix | 2 +- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/pkgs/development/compilers/flutter/artifacts/hashes.nix b/pkgs/development/compilers/flutter/artifacts/hashes.nix index 8ae74bff17ed..551975acf662 100644 --- a/pkgs/development/compilers/flutter/artifacts/hashes.nix +++ b/pkgs/development/compilers/flutter/artifacts/hashes.nix @@ -24,15 +24,52 @@ # --[no-]flutter_runner Precache the flutter runner artifacts. # --[no-]use-unsigned-mac-binaries Precache the unsigned macOS binaries when available. +# Schema: +# ${flutterVersion}.${targetPlatform}.${hostPlatform} +# +# aarch64-darwin as a host is not yet supported. +# https://github.com/flutter/flutter/issues/60118 { "3.13.8" = { - android = "sha256-Uc36aBq8wQo2aEvjAPOoixZElWOE/GNRm2GUfhbwT3Y="; - fuchsia = "sha256-eu0BERdz53CkSexbpu3KA7O6Q4g0s9SGD3t1Snsk3Fk="; - ios = "sha256-QwkeGnutTVsm682CqxRtEd9rKUvN7zlAJcqkvAQYwao="; - linux = "sha256-0gIOwux3YBdmcXgwICr8dpftj1CauaBUX8Rt5GG0WSs="; - macos = "sha256-9WqCJQ37mcGc5tzfqQoY5CqHWHGTizjXf9p73bdnNWc="; - universal = "sha256-wATt1UPjo/fh7RFO1vvcUAdo0dMAaaOUIuzYodsM0v0="; - web = "sha256-DVXJOOFxv7tKt3d0NaYMexkphEcr7+gDFV67I6iAYa0="; - windows = "sha256-s8fJtwQkuZaGXr6vrPiKfpwP/NfewbETwyp9ERGqHYI="; + android = { + x86_64-linux = "sha256-Uc36aBq8wQo2aEvjAPOoixZElWOE/GNRm2GUfhbwT3Y="; + aarch64-linux = "sha256-Uc36aBq8wQo2aEvjAPOoixZElWOE/GNRm2GUfhbwT3Y="; + x86_64-darwin = "sha256-v/6/GTj7732fEOIgSaoM00yaw2qNwOMuvbuoCvii7vQ="; + }; + fuchsia = { + x86_64-linux = "sha256-eu0BERdz53CkSexbpu3KA7O6Q4g0s9SGD3t1Snsk3Fk="; + aarch64-linux = "sha256-eu0BERdz53CkSexbpu3KA7O6Q4g0s9SGD3t1Snsk3Fk="; + x86_64-darwin = "sha256-eu0BERdz53CkSexbpu3KA7O6Q4g0s9SGD3t1Snsk3Fk="; + }; + ios = { + x86_64-linux = "sha256-QwkeGnutTVsm682CqxRtEd9rKUvN7zlAJcqkvAQYwao="; + aarch64-linux = "sha256-QwkeGnutTVsm682CqxRtEd9rKUvN7zlAJcqkvAQYwao="; + x86_64-darwin = "sha256-QwkeGnutTVsm682CqxRtEd9rKUvN7zlAJcqkvAQYwao="; + }; + linux = { + x86_64-linux = "sha256-0gIOwux3YBdmcXgwICr8dpftj1CauaBUX8Rt5GG0WSs="; + aarch64-linux = "sha256-drGHsuJoOCLqrhVrXczqJRCOtpeWVlqdWW0OSMS/l5M="; + x86_64-darwin = "sha256-0gIOwux3YBdmcXgwICr8dpftj1CauaBUX8Rt5GG0WSs="; + }; + macos = { + x86_64-linux = "sha256-9WqCJQ37mcGc5tzfqQoY5CqHWHGTizjXf9p73bdnNWc="; + aarch64-linux = "sha256-9WqCJQ37mcGc5tzfqQoY5CqHWHGTizjXf9p73bdnNWc="; + x86_64-darwin = "sha256-9WqCJQ37mcGc5tzfqQoY5CqHWHGTizjXf9p73bdnNWc="; + }; + universal = { + x86_64-linux = "sha256-wATt1UPjo/fh7RFO1vvcUAdo0dMAaaOUIuzYodsM0v0="; + aarch64-linux = "sha256-Z9bszNaIpCccG7OfvE5WFsw36dITiyCQAZ6p29+Yq68="; + x86_64-darwin = "sha256-qN5bAXRfQ78TWF3FLBIxWzUB5y5OrZVQTEilY5J/+2k="; + }; + web = { + x86_64-linux = "sha256-DVXJOOFxv7tKt3d0NaYMexkphEcr7+gDFV67I6iAYa0="; + aarch64-linux = "sha256-DVXJOOFxv7tKt3d0NaYMexkphEcr7+gDFV67I6iAYa0="; + x86_64-darwin = "sha256-DVXJOOFxv7tKt3d0NaYMexkphEcr7+gDFV67I6iAYa0="; + }; + windows = { + x86_64-linux = "sha256-s8fJtwQkuZaGXr6vrPiKfpwP/NfewbETwyp9ERGqHYI="; + aarch64-linux = "sha256-s8fJtwQkuZaGXr6vrPiKfpwP/NfewbETwyp9ERGqHYI="; + x86_64-darwin = "sha256-s8fJtwQkuZaGXr6vrPiKfpwP/NfewbETwyp9ERGqHYI="; + }; }; } diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 2da1140889ee..0dff9c0738fc 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -56,7 +56,7 @@ let inherit flutter; supportedTargetPlatforms = [ ]; }; - hash = artifactHashes.${platform} or ""; + hash = artifactHashes.${platform}.${stdenv.hostPlatform.system} or ""; }; }).overrideAttrs ( if builtins.pathExists ./artifacts/overrides/${platform}.nix From 456779edc2c55bb0cdd4220d1850b4a7e1ff161a Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 22:31:19 +1100 Subject: [PATCH 27/34] flutter: Move artifact override logic to fetch-artifacts.nix --- .../compilers/flutter/artifacts/fetch-artifacts.nix | 9 ++++++++- .../flutter/artifacts/prepare-artifacts.nix | 13 +++++++++---- pkgs/development/compilers/flutter/wrapper.nix | 13 ++----------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix index 96e70acf29bc..a0b7415b05ee 100644 --- a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix +++ b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix @@ -22,7 +22,14 @@ let in runCommand "flutter-artifacts-${platform}" { - nativeBuildInputs = [ flutter unzip ]; + nativeBuildInputs = [ + (flutter.override { + # Use a version of Flutter with just enough capabilities to download + # artifacts. + supportedTargetPlatforms = [ ]; + }) + unzip + ]; NIX_FLUTTER_TOOLS_VM_OPTIONS = "--root-certs-file=${cacert}/etc/ssl/certs/ca-bundle.crt"; diff --git a/pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix b/pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix index e248869fdfb2..9714d25c6f9b 100644 --- a/pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix +++ b/pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix @@ -1,10 +1,11 @@ -{ stdenv -, lib +{ lib +, stdenv +, callPackage , autoPatchelfHook , src }: -stdenv.mkDerivation { +(stdenv.mkDerivation { inherit (src) name; inherit src; @@ -18,4 +19,8 @@ stdenv.mkDerivation { runHook postInstall ''; -} +}).overrideAttrs ( + if builtins.pathExists ./overrides/${src.platform}.nix + then callPackage ./overrides/${src.platform}.nix { } + else ({ ... }: { }) +) diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index 0dff9c0738fc..c35448d5bac3 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -50,19 +50,10 @@ let (callPackage ./artifacts/prepare-artifacts.nix { src = callPackage ./artifacts/fetch-artifacts.nix { inherit platform; - # Use a version of Flutter with just enough capabilities to download - # artifacts. - flutter = callPackage ./wrapper.nix { - inherit flutter; - supportedTargetPlatforms = [ ]; - }; + flutter = callPackage ./wrapper.nix { inherit flutter; }; hash = artifactHashes.${platform}.${stdenv.hostPlatform.system} or ""; }; - }).overrideAttrs ( - if builtins.pathExists ./artifacts/overrides/${platform}.nix - then callPackage ./artifacts/overrides/${platform}.nix { } - else ({ ... }: { }) - )); + })); cacheDir = symlinkJoin rec { name = "flutter-cache-dir"; From 27f61f5e1b695a9accb71886f380513e1b0e4ef3 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 22:32:54 +1100 Subject: [PATCH 28/34] flutter: Remove existing .git directories --- pkgs/development/compilers/flutter/flutter.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index befff3516b89..45e50e50d821 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -47,14 +47,13 @@ let # The flutter_tools package tries to run many Git commands. In most # cases, unexpected output is handled gracefully, but commands are never # expected to fail completely. A blank repository needs to be created. - if [ ! -d .git ]; then - git init -b nixpkgs - GIT_AUTHOR_NAME=Nixpkgs GIT_COMMITTER_NAME=Nixpkgs \ - GIT_AUTHOR_EMAIL= GIT_COMMITTER_EMAIL= \ - GIT_AUTHOR_DATE='1/1/1970 00:00:00 +0000' GIT_COMMITTER_DATE='1/1/1970 00:00:00 +0000' \ - git commit --allow-empty -m "Initial commit" - (. '${../../../build-support/fetchgit/deterministic-git}'; make_deterministic_repo .) - fi + rm -rf .git # Remove any existing Git directory + git init -b nixpkgs + GIT_AUTHOR_NAME=Nixpkgs GIT_COMMITTER_NAME=Nixpkgs \ + GIT_AUTHOR_EMAIL= GIT_COMMITTER_EMAIL= \ + GIT_AUTHOR_DATE='1/1/1970 00:00:00 +0000' GIT_COMMITTER_DATE='1/1/1970 00:00:00 +0000' \ + git commit --allow-empty -m "Initial commit" + (. '${../../../build-support/fetchgit/deterministic-git}'; make_deterministic_repo .) mkdir -p bin/cache From 981831870d06f028245751b64fd5a3c012343ede Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 22:41:50 +1100 Subject: [PATCH 29/34] flutter: Remove runHooks in fetch-artifacts.nix runCommand --- .../compilers/flutter/artifacts/fetch-artifacts.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix index a0b7415b05ee..8c42c8a074a8 100644 --- a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix +++ b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix @@ -41,10 +41,6 @@ runCommand "flutter-artifacts-${platform}" inherit platform; }; } '' - runHook preBuild - 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))} - - runHook postBuild '' From d8b20d93adc539114de5401514f4d937aaac34aa Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Mon, 23 Oct 2023 23:05:25 +1100 Subject: [PATCH 30/34] flutter: Remove FLUTTER_CACHE_DIR --- .../flutter/artifacts/fetch-artifacts.nix | 28 ++++++---- .../flutter/patches/flutter3/move-cache.patch | 53 ------------------- .../development/compilers/flutter/wrapper.nix | 3 -- 3 files changed, 18 insertions(+), 66 deletions(-) delete mode 100644 pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch diff --git a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix index 8c42c8a074a8..baa3e8e56e70 100644 --- a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix +++ b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix @@ -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" '' diff --git a/pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch b/pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch deleted file mode 100644 index cc6e5e8f49e0..000000000000 --- a/pkgs/development/compilers/flutter/patches/flutter3/move-cache.patch +++ /dev/null @@ -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 { diff --git a/pkgs/development/compilers/flutter/wrapper.nix b/pkgs/development/compilers/flutter/wrapper.nix index c35448d5bac3..38c2eb289310 100644 --- a/pkgs/development/compilers/flutter/wrapper.nix +++ b/pkgs/development/compilers/flutter/wrapper.nix @@ -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 "$@" ''; From 133d03eb429f942ff7b901395655d305fe38760a Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Tue, 24 Oct 2023 20:37:25 +1100 Subject: [PATCH 31/34] flutter: Set FLUTTER_ALREADY_LOCKED to prevent writes to the immutable lockfile --- pkgs/development/compilers/flutter/flutter.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 45e50e50d821..250aaae9951c 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -86,6 +86,7 @@ let ln -s "$out/bin/cache/dart-sdk/bin/dart" "$out/bin/dart" makeShellWrapper "$out/bin/dart" "$out/bin/flutter" \ --set-default FLUTTER_ROOT "$out" \ + --set FLUTTER_ALREADY_LOCKED true \ --add-flags "--disable-dart-dev \$NIX_FLUTTER_TOOLS_VM_OPTIONS $out/bin/cache/flutter_tools.snapshot" runHook postInstall From 03ae92a17d0f9683a1da5eaee77b0497a0d7ba66 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Tue, 24 Oct 2023 20:39:59 +1100 Subject: [PATCH 32/34] flutter: Remove aarch64-darwin platform There are no aarch64-darwin host artifacts. Development should be done with Rosetta 2. - https://github.com/flutter/flutter/issues/60118 - https://github.com/flutter/flutter/issues/69157 - https://github.com/flutter/flutter/issues/101138 --- pkgs/development/compilers/flutter/flutter.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix index 250aaae9951c..69efe678dc5a 100644 --- a/pkgs/development/compilers/flutter/flutter.nix +++ b/pkgs/development/compilers/flutter/flutter.nix @@ -122,7 +122,7 @@ let ''; homepage = "https://flutter.dev"; license = licenses.bsd3; - platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; maintainers = with maintainers; [ babariviere ericdallo FlafyDev hacker1024 ]; }; }; From 145c291ca67f58813547a47b0a1837c303649ce7 Mon Sep 17 00:00:00 2001 From: hacker1024 Date: Tue, 24 Oct 2023 21:14:19 +1100 Subject: [PATCH 33/34] fetchDartDeps: Use add milliseconds to date in package_config.json This in compliance with the format specification. https://github.com/dart-lang/language/blob/main/accepted/2.8/language-versioning/package-config-file-v2.md --- pkgs/build-support/dart/fetch-dart-deps/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/dart/fetch-dart-deps/default.nix b/pkgs/build-support/dart/fetch-dart-deps/default.nix index 66050f9fdf35..e6e5cf76a60f 100644 --- a/pkgs/build-support/dart/fetch-dart-deps/default.nix +++ b/pkgs/build-support/dart/fetch-dart-deps/default.nix @@ -203,7 +203,7 @@ let # usage. jq -S ' .packages[] |= . + { rootUri: .rootUri | gsub("'"$PUB_CACHE"'"; "${hook.deps}/cache/.pub-cache") } - | .generated |= "1970-01-01T00:00:00Z" + | .generated |= "1970-01-01T00:00:00.000Z" ' .dart_tool/package_config.json > $out runHook postBuild From 9e046794a8a9bc168e970cc12dfd39623a7ed9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Thu, 21 Dec 2023 11:57:23 +0100 Subject: [PATCH 34/34] flutter: dont fail on missing lockfile --- .../development/compilers/flutter/artifacts/fetch-artifacts.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix index baa3e8e56e70..e0c1440a604f 100644 --- a/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix +++ b/pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix @@ -47,7 +47,7 @@ runCommand "flutter-artifacts-${platform}" 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" + rm -rf "$FLUTTER_ROOT/bin/cache/lockfile" find "$FLUTTER_ROOT" -type l -lname '${flutter'}/*' -delete cp -r bin/cache "$out"