2023-04-29 16:46:19 +00:00
|
|
|
|
{ version
|
|
|
|
|
, engineVersion
|
2021-01-09 10:05:03 +00:00
|
|
|
|
, patches
|
|
|
|
|
, dart
|
2021-02-05 17:12:51 +00:00
|
|
|
|
, src
|
2024-01-02 11:29:13 +00:00
|
|
|
|
, pubspecLockFile
|
|
|
|
|
, vendorHash
|
|
|
|
|
, depsListFile
|
2021-02-05 17:12:51 +00:00
|
|
|
|
, lib
|
2023-04-29 16:46:19 +00:00
|
|
|
|
, stdenv
|
2024-01-02 11:29:13 +00:00
|
|
|
|
, callPackage
|
|
|
|
|
, makeWrapper
|
2023-07-15 17:15:38 +00:00
|
|
|
|
, darwin
|
2023-04-29 16:46:19 +00:00
|
|
|
|
, git
|
|
|
|
|
, which
|
2023-05-24 13:37:59 +00:00
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
|
let
|
2024-01-02 11:29:13 +00:00
|
|
|
|
tools = callPackage ./flutter-tools.nix {
|
|
|
|
|
inherit dart version;
|
|
|
|
|
flutterSrc = src;
|
|
|
|
|
inherit patches;
|
|
|
|
|
inherit pubspecLockFile vendorHash depsListFile;
|
|
|
|
|
};
|
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
|
unwrapped =
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
|
name = "flutter-${version}-unwrapped";
|
|
|
|
|
inherit src patches version;
|
|
|
|
|
|
|
|
|
|
buildInputs = [ git ];
|
2024-01-02 11:29:13 +00:00
|
|
|
|
nativeBuildInputs = [ makeWrapper ]
|
2023-07-15 17:15:38 +00:00
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
|
2023-04-29 16:46:19 +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
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
|
patchShebangs --build ./bin/
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
buildPhase = ''
|
2024-01-02 11:29:13 +00:00
|
|
|
|
# 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.
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
# 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
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
|
|
echo -n "${version}" > version
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
|
cp -r . $out
|
2024-01-02 11:29:13 +00:00
|
|
|
|
rm -rf $out/bin/cache/dart-sdk
|
2023-04-29 16:46:19 +00:00
|
|
|
|
ln -sf ${dart} $out/bin/cache/dart-sdk
|
|
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
|
# 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"
|
|
|
|
|
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"
|
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
|
runHook postInstall
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
2023-07-15 17:15:38 +00:00
|
|
|
|
nativeInstallCheckInputs = [ which ]
|
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ];
|
2023-04-29 16:46:19 +00:00
|
|
|
|
installCheckPhase = ''
|
|
|
|
|
runHook preInstallCheck
|
|
|
|
|
|
|
|
|
|
export HOME="$(mktemp -d)"
|
|
|
|
|
$out/bin/flutter config --android-studio-dir $HOME
|
|
|
|
|
$out/bin/flutter config --android-sdk $HOME
|
2024-01-02 11:29:13 +00:00
|
|
|
|
$out/bin/flutter --version | fgrep -q '${builtins.substring 0 10 engineVersion}'
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
|
|
runHook postInstallCheck
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
passthru = {
|
2024-01-02 11:29:13 +00:00
|
|
|
|
inherit dart engineVersion tools;
|
2023-04-29 16:46:19 +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.
|
|
|
|
|
sdk = unwrapped;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
2024-01-02 11:29:13 +00:00
|
|
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
maintainers = with maintainers; [ babariviere ericdallo FlafyDev hacker1024 ];
|
2023-04-29 16:46:19 +00:00
|
|
|
|
};
|
2022-02-20 05:27:41 +00:00
|
|
|
|
};
|
|
|
|
|
in
|
2023-04-29 16:46:19 +00:00
|
|
|
|
unwrapped
|