2022-11-14 02:11:49 +00:00
|
|
|
|
{ version
|
2023-04-23 04:44:46 +00:00
|
|
|
|
, engineVersion
|
2021-01-06 20:38:03 +00:00
|
|
|
|
, patches
|
|
|
|
|
, dart
|
2021-01-29 18:03:58 +00:00
|
|
|
|
, src
|
2023-04-12 14:09:42 +00:00
|
|
|
|
, lib
|
2021-01-15 20:21:25 +00:00
|
|
|
|
, stdenv
|
2023-07-05 08:25:32 +00:00
|
|
|
|
, darwin
|
2023-04-13 06:14:22 +00:00
|
|
|
|
, git
|
2021-09-25 02:09:00 +00:00
|
|
|
|
, which
|
2023-04-27 06:52:51 +00:00
|
|
|
|
}:
|
2019-12-24 17:01:45 +00:00
|
|
|
|
|
2023-02-17 13:43:17 +00:00
|
|
|
|
let
|
2023-04-13 13:19:16 +00:00
|
|
|
|
unwrapped =
|
2023-02-17 13:43:17 +00:00
|
|
|
|
stdenv.mkDerivation {
|
2023-04-13 09:29:42 +00:00
|
|
|
|
name = "flutter-${version}-unwrapped";
|
2023-04-12 16:40:44 +00:00
|
|
|
|
inherit src patches version;
|
2023-02-17 13:43:17 +00:00
|
|
|
|
|
2023-04-12 16:40:44 +00:00
|
|
|
|
outputs = [ "out" "cache" ];
|
2023-02-17 13:43:17 +00:00
|
|
|
|
|
2023-04-14 15:59:31 +00:00
|
|
|
|
buildInputs = [ git ];
|
2023-07-05 08:25:32 +00:00
|
|
|
|
nativeBuildInputs = [ ]
|
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
|
2023-02-17 13:43:17 +00:00
|
|
|
|
|
2023-04-23 04:44:46 +00:00
|
|
|
|
preConfigure = ''
|
|
|
|
|
if [ "$(< bin/internal/engine.version)" != '${engineVersion}' ]; then
|
|
|
|
|
echo 1>&2 "The given engine version (${engineVersion}) does not match the version required by the Flutter SDK ($(< bin/internal/engine.version))."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
'';
|
|
|
|
|
|
2023-02-17 13:43:17 +00:00
|
|
|
|
postPatch = ''
|
|
|
|
|
patchShebangs --build ./bin/
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
|
export FLUTTER_ROOT="$(pwd)"
|
|
|
|
|
export FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools"
|
|
|
|
|
export SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart"
|
|
|
|
|
|
|
|
|
|
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}"
|
|
|
|
|
|
2023-04-12 16:40:44 +00:00
|
|
|
|
# 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
|
2023-02-17 13:43:17 +00:00
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
echo -n "${version}" > version
|
|
|
|
|
|
2023-04-14 15:59:31 +00:00
|
|
|
|
# Certain prebuilts should be replaced with Nix-built (or at least Nix-patched) equivalents.
|
|
|
|
|
rm -r \
|
2023-07-05 08:25:32 +00:00
|
|
|
|
$FLUTTER_ROOT/bin/cache/dart-sdk \
|
|
|
|
|
$FLUTTER_ROOT/bin/cache/artifacts/engine
|
2023-02-17 13:43:17 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
|
cp -r . $out
|
|
|
|
|
ln -sf ${dart} $out/bin/cache/dart-sdk
|
|
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
2023-07-05 08:25:32 +00:00
|
|
|
|
nativeInstallCheckInputs = [ which ]
|
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
|
2023-02-17 13:43:17 +00:00
|
|
|
|
installCheckPhase = ''
|
|
|
|
|
runHook preInstallCheck
|
|
|
|
|
|
|
|
|
|
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}'
|
|
|
|
|
|
|
|
|
|
runHook postInstallCheck
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
passthru = {
|
2023-06-30 12:00:56 +00:00
|
|
|
|
inherit dart engineVersion;
|
2023-02-17 13:43:17 +00:00
|
|
|
|
# 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.
|
2023-04-13 13:19:16 +00:00
|
|
|
|
sdk = unwrapped;
|
2023-02-17 13:43:17 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
|
description = "Flutter is Google's SDK for building mobile, web and desktop with Dart";
|
|
|
|
|
longDescription = ''
|
|
|
|
|
Flutter is Google’s UI toolkit for building beautiful,
|
|
|
|
|
natively compiled applications for mobile, web, and desktop from a single codebase.
|
|
|
|
|
'';
|
|
|
|
|
homepage = "https://flutter.dev";
|
|
|
|
|
license = licenses.bsd3;
|
2023-07-05 08:25:32 +00:00
|
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2023-09-13 15:37:52 +00:00
|
|
|
|
maintainers = with maintainers; [ babariviere ericdallo FlafyDev hacker1024 ];
|
2023-02-17 13:43:17 +00:00
|
|
|
|
};
|
2023-04-14 15:59:31 +00:00
|
|
|
|
};
|
2023-02-17 13:43:17 +00:00
|
|
|
|
in
|
2023-04-13 13:19:16 +00:00
|
|
|
|
unwrapped
|