Merge pull request #108611 from thiagokokada/flutter-refactor-bump

flutter: reduce derivation size and refactor
This commit is contained in:
Kevin Cox 2021-01-06 17:15:04 -05:00 committed by GitHub
commit 544d4f3a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 21 deletions

View File

@ -1,5 +1,4 @@
{ callPackage, dart }:
let
dart_stable = dart.override { version = "2.10.0"; };
dart_beta = dart.override { version = "2.10.0"; };
@ -8,7 +7,8 @@ let
getPatches = dir:
let files = builtins.attrNames (builtins.readDir dir);
in map (f: dir + ("/" + f)) files;
in {
in
{
mkFlutter = mkFlutter;
stable = mkFlutter rec {
pname = "flutter";

View File

@ -1,10 +1,36 @@
{ channel, pname, version, sha256Hash, patches, dart
, filename ? "flutter_linux_${version}-${channel}.tar.xz"}:
{ bash, buildFHSUserEnv, cacert, coreutils, git, makeWrapper, runCommand, stdenv
, fetchurl, alsaLib, dbus, expat, libpulseaudio, libuuid, libX11, libxcb
, libXcomposite, libXcursor, libXdamage, libXfixes, libGL, nspr, nss, systemd }:
{ channel
, pname
, version
, sha256Hash
, patches
, dart
, filename ? "flutter_linux_${version}-${channel}.tar.xz"
}:
{ bash
, buildFHSUserEnv
, cacert
, coreutils
, git
, runCommand
, stdenv
, fetchurl
, alsaLib
, dbus
, expat
, libpulseaudio
, libuuid
, libX11
, libxcb
, libXcomposite
, libXcursor
, libXdamage
, libXfixes
, libGL
, nspr
, nss
, systemd
}:
let
drvName = "flutter-${channel}-${version}";
flutter = stdenv.mkDerivation {
@ -16,7 +42,7 @@ let
sha256 = sha256Hash;
};
buildInputs = [ makeWrapper git ];
buildInputs = [ git ];
inherit patches;
@ -31,28 +57,27 @@ let
SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot"
STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp"
SCRIPT_PATH="$FLUTTER_TOOLS_DIR/bin/flutter_tools.dart"
DART_SDK_PATH="$FLUTTER_ROOT/bin/cache/dart-sdk"
DART="$DART_SDK_PATH/bin/dart"
PUB="$DART_SDK_PATH/bin/pub"
DART_SDK_PATH="${dart}"
HOME=../.. # required for pub upgrade --offline, ~/.pub-cache
# path is relative otherwise it's replaced by /build/flutter
(cd "$FLUTTER_TOOLS_DIR" && "$PUB" upgrade --offline)
(cd "$FLUTTER_TOOLS_DIR" && ${dart}/bin/pub upgrade --offline)
local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)"
"$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
${dart}/bin/dart --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
echo "$revision" > "$STAMP_PATH"
echo -n "${version}" > version
rm -rf bin/cache/{artifacts,downloads}
rm -rf bin/cache/{artifacts,dart-sdk,downloads}
rm -f bin/cache/*.stamp
'';
installPhase = ''
mkdir -p $out
cp -r . $out
mkdir -p $out/bin/cache/
ln -sf ${dart} $out/bin/cache/dart-sdk
'';
};
@ -100,7 +125,9 @@ let
];
};
in runCommand drvName {
in
runCommand drvName
{
startScript = ''
#!${bash}/bin/bash
export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"}
@ -126,8 +153,4 @@ in runCommand drvName {
echo -n "$startScript" > $out/bin/${pname}
chmod +x $out/bin/${pname}
mkdir -p $out/bin/cache/dart-sdk/
cp -r ${dart}/* $out/bin/cache/dart-sdk/
ln $out/bin/cache/dart-sdk/bin/dart $out/bin/dart
''