about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/flutter/flutter.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/flutter/flutter.nix')
-rw-r--r--nixpkgs/pkgs/development/compilers/flutter/flutter.nix65
1 files changed, 44 insertions, 21 deletions
diff --git a/nixpkgs/pkgs/development/compilers/flutter/flutter.nix b/nixpkgs/pkgs/development/compilers/flutter/flutter.nix
index 7fda2d616f3e..a7ec87322507 100644
--- a/nixpkgs/pkgs/development/compilers/flutter/flutter.nix
+++ b/nixpkgs/pkgs/development/compilers/flutter/flutter.nix
@@ -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
+, lib, 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"}
@@ -110,7 +137,7 @@ in runCommand drvName {
   preferLocalBuild = true;
   allowSubstitutes = false;
   passthru = { unwrapped = flutter; };
-  meta = with stdenv.lib; {
+  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,
@@ -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
 ''