flutter: Redesign wrapping architecture
The following principles are now in place: - All wrappers will include SDK file symlinks. There is not much of a reason to not do so, and removing the option to omit it makes it easier to understand what each wrapper does. - There is no longer a way to get the previous derivation from a wrapper. This could yield unexpected results based on the wrapping order. Instead, "sdk", "unwrapped", and "noFHS" passthru attributes are provided where appropriate.
This commit is contained in:
parent
aa33cb9956
commit
341fa709ff
@ -3,7 +3,6 @@ let
|
||||
mkFlutter = opts: callPackage (import ./flutter.nix opts) { };
|
||||
wrapFlutter = flutter: callPackage (import ./wrapper.nix) { flutter = flutter; };
|
||||
mkFlutterFHS = flutter: callPackage (import ./fhs.nix) { flutter = flutter; };
|
||||
mkFakeSdk = flutter: callPackage (import ./fake-sdk.nix) { flutter = flutter; };
|
||||
getPatches = dir:
|
||||
let files = builtins.attrNames (builtins.readDir dir);
|
||||
in map (f: dir + ("/" + f)) files;
|
||||
@ -29,7 +28,7 @@ let
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit mkFlutter wrapFlutter mkFlutterFHS mkFakeSdk flutterDrv;
|
||||
inherit mkFlutter wrapFlutter mkFlutterFHS flutterDrv;
|
||||
stable = flutterDrv {
|
||||
version = "3.3.3";
|
||||
dartVersion = "2.18.2";
|
||||
|
@ -1,15 +0,0 @@
|
||||
{ flutter, symlinkJoin }:
|
||||
|
||||
symlinkJoin {
|
||||
name = "flutter-fake-${flutter.name}";
|
||||
paths = [ flutter flutter.unwrapped ];
|
||||
|
||||
inherit (flutter) passthru;
|
||||
|
||||
meta = flutter.meta // {
|
||||
longDescription = ''
|
||||
${flutter.meta.longDescription}
|
||||
Modified binaries are linked into the original SDK directory for use with tools that use the whole SDK.
|
||||
'';
|
||||
};
|
||||
}
|
@ -7,11 +7,11 @@
|
||||
, supportsAndroidEmulator ? stdenv.isLinux
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
# Wrap flutter inside an fhs user env to allow execution of binary,
|
||||
# like adb from $ANDROID_HOME or java from android-studio.
|
||||
self = buildFHSUserEnv {
|
||||
name = flutter.name;
|
||||
(callPackage ./sdk-symlink.nix { }) (buildFHSUserEnv rec {
|
||||
name = "${flutter.name}-fhs";
|
||||
|
||||
multiPkgs = pkgs: with pkgs; ([
|
||||
# Flutter only use these certificates
|
||||
@ -60,12 +60,18 @@ let
|
||||
|
||||
runScript = "flutter";
|
||||
|
||||
extraInstallCommands = ''
|
||||
# By default, the derivation name is used as the binary name.
|
||||
# This is not the desired behaviour in this case.
|
||||
# https://github.com/NixOS/nixpkgs/blob/cb4536bf3606a7b6b54b69afe22ccd82e2906d92/pkgs/build-support/build-fhs-userenv/default.nix#L43
|
||||
mv $out/bin/${name} $out/bin/flutter
|
||||
'';
|
||||
|
||||
passthru = flutter.passthru // {
|
||||
wrapped = flutter;
|
||||
nonFHS = flutter;
|
||||
mkFlutterApp = callPackage ../../../build-support/flutter {
|
||||
flutter = callPackage ./fhs.nix { supportsAndroidEmulator = false; };
|
||||
};
|
||||
fakeSdk = callPackage ./fake-sdk.nix { flutter = self; };
|
||||
};
|
||||
|
||||
meta = flutter.meta // {
|
||||
@ -74,6 +80,4 @@ let
|
||||
Wrapped in a FHS environment to improve compatibility with internal tools and tools in the ecosystem.
|
||||
'';
|
||||
};
|
||||
};
|
||||
in
|
||||
self
|
||||
})
|
||||
|
@ -10,6 +10,8 @@
|
||||
, which
|
||||
}:
|
||||
|
||||
let
|
||||
self =
|
||||
stdenv.mkDerivation {
|
||||
name = "$flutter-${version}-unwrapped";
|
||||
|
||||
@ -73,6 +75,11 @@ stdenv.mkDerivation {
|
||||
|
||||
passthru = {
|
||||
inherit dart;
|
||||
|
||||
# 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 = self;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
@ -87,3 +94,6 @@ stdenv.mkDerivation {
|
||||
maintainers = with maintainers; [ babariviere ericdallo ];
|
||||
};
|
||||
}
|
||||
;
|
||||
in
|
||||
self
|
||||
|
24
pkgs/development/compilers/flutter/sdk-symlink.nix
Normal file
24
pkgs/development/compilers/flutter/sdk-symlink.nix
Normal file
@ -0,0 +1,24 @@
|
||||
{ symlinkJoin }: flutter:
|
||||
|
||||
let
|
||||
self =
|
||||
symlinkJoin {
|
||||
name = "${flutter.name}-sdk-links";
|
||||
paths = [ flutter flutter.sdk ];
|
||||
|
||||
passthru = flutter.passthru // {
|
||||
# Update the SDK attribute.
|
||||
# This allows any modified SDK files to be included
|
||||
# in future invocations.
|
||||
sdk = self;
|
||||
};
|
||||
|
||||
meta = flutter.meta // {
|
||||
longDescription = ''
|
||||
${flutter.meta.longDescription}
|
||||
Modified binaries are linked into the original SDK directory for use with tools that use the whole SDK.
|
||||
'';
|
||||
};
|
||||
};
|
||||
in
|
||||
self
|
@ -79,7 +79,7 @@ let
|
||||
cppFlags = map (pkg: "-isystem ${lib.getOutput "dev" pkg}/include") appStaticBuildDeps;
|
||||
linkerFlags = map (pkg: "-rpath,${lib.getOutput "lib" pkg}/lib") appRuntimeDeps;
|
||||
in
|
||||
runCommandLocal "flutter"
|
||||
(callPackage ./sdk-symlink.nix { }) (runCommandLocal "flutter-wrapped"
|
||||
{
|
||||
buildInputs = [ makeWrapper ];
|
||||
|
||||
@ -90,10 +90,6 @@ runCommandLocal "flutter"
|
||||
inherit (flutter) meta;
|
||||
} ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
mkdir -p $out/bin/cache/
|
||||
ln -sf ${flutter.dart} $out/bin/cache/dart-sdk
|
||||
|
||||
makeWrapper '${immutableFlutter}' $out/bin/flutter \
|
||||
--set-default ANDROID_EMULATOR_USE_SYSTEM_LIBS 1 \
|
||||
--prefix PATH : '${lib.makeBinPath buildTools}' \
|
||||
@ -101,4 +97,4 @@ runCommandLocal "flutter"
|
||||
--prefix CXXFLAGS "''\t" '${builtins.concatStringsSep " " cppFlags}' \
|
||||
--prefix LDFLAGS "''\t" '${builtins.concatStringsSep " " (map (flag: "-Wl,${flag}") linkerFlags)}' \
|
||||
--suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath appPrebuiltDeps}'
|
||||
''
|
||||
'')
|
||||
|
Loading…
Reference in New Issue
Block a user