flutter: small refactorings in derivation
This commit is contained in:
parent
f5294b802d
commit
910d06bb90
4 changed files with 26 additions and 25 deletions
|
@ -1,17 +1,22 @@
|
|||
{ callPackage, dart }:
|
||||
{ callPackage, fetchurl, dart }:
|
||||
let
|
||||
mkFlutter = opts: callPackage (import ./flutter.nix opts) { };
|
||||
getPatches = dir:
|
||||
let files = builtins.attrNames (builtins.readDir dir);
|
||||
in map (f: dir + ("/" + f)) files;
|
||||
version = "1.22.4";
|
||||
channel = "stable";
|
||||
filename = "flutter_linux_${version}-${channel}.tar.xz";
|
||||
in
|
||||
{
|
||||
mkFlutter = mkFlutter;
|
||||
stable = mkFlutter rec {
|
||||
inherit dart;
|
||||
inherit dart version;
|
||||
pname = "flutter";
|
||||
version = "1.22.4";
|
||||
sha256Hash = "0qalgav9drqddcj8lfvl9ddf3325n953pvkmgha47lslg9sa88zw";
|
||||
patches = getPatches ./patches/stable;
|
||||
src = fetchurl {
|
||||
url = "https://storage.googleapis.com/flutter_infra/releases/${channel}/linux/${filename}";
|
||||
sha256 = "0qalgav9drqddcj8lfvl9ddf3325n953pvkmgha47lslg9sa88zw";
|
||||
};
|
||||
patches = getPatches ./patches;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
{ pname
|
||||
, version
|
||||
, sha256Hash
|
||||
, patches
|
||||
, dart
|
||||
, channel ? "stable"
|
||||
, filename ? "flutter_linux_${version}-${channel}.tar.xz"
|
||||
, src
|
||||
}:
|
||||
|
||||
{ bash
|
||||
|
@ -33,19 +31,13 @@
|
|||
, systemd
|
||||
}:
|
||||
let
|
||||
drvName = "flutter-${channel}-${version}";
|
||||
drvName = "flutter-${version}";
|
||||
flutter = stdenv.mkDerivation {
|
||||
name = "${drvName}-unwrapped";
|
||||
|
||||
src = fetchurl {
|
||||
url =
|
||||
"https://storage.googleapis.com/flutter_infra/releases/${channel}/linux/${filename}";
|
||||
sha256 = sha256Hash;
|
||||
};
|
||||
|
||||
buildInputs = [ git ];
|
||||
|
||||
inherit patches;
|
||||
inherit src patches;
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs --build ./bin/
|
||||
|
@ -53,25 +45,29 @@ let
|
|||
'';
|
||||
|
||||
buildPhase = ''
|
||||
FLUTTER_ROOT=$(pwd)
|
||||
FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools"
|
||||
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="${dart}"
|
||||
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}"
|
||||
|
||||
HOME=../.. # required for pub upgrade --offline, ~/.pub-cache
|
||||
# path is relative otherwise it's replaced by /build/flutter
|
||||
|
||||
(cd "$FLUTTER_TOOLS_DIR" && ${dart}/bin/pub upgrade --offline)
|
||||
pushd "$FLUTTER_TOOLS_DIR"
|
||||
${dart}/bin/pub get --offline
|
||||
popd
|
||||
|
||||
local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)"
|
||||
${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,dart-sdk,downloads}
|
||||
rm -f bin/cache/*.stamp
|
||||
rm -r bin/cache/{artifacts,dart-sdk,downloads}
|
||||
rm bin/cache/*.stamp
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
|
|
Loading…
Reference in a new issue