Commit 8ab57cea authored by Philip Hayes's avatar Philip Hayes
Browse files

flutter: prevent built iOS/macOS apps from containing links to nix store

parent 492e603e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
{ useNixpkgsEngine ? false, callPackage, fetchzip, fetchFromGitHub, dart, lib, stdenv }@args:
{ useNixpkgsEngine ? false, callPackage, fetchzip, fetchFromGitHub, dart, lib, stdenv }:
let
  mkCustomFlutter = args: callPackage ./flutter.nix args;
  wrapFlutter = flutter: callPackage ./wrapper.nix { inherit flutter; };
@@ -19,7 +19,7 @@ let
    , pubspecLock
    , artifactHashes
    , channel
    }@fargs:
    }:
    let
      args = {
        inherit version engineVersion engineSwiftShaderRev engineSwiftShaderHash engineHashes enginePatches patches pubspecLock artifactHashes useNixpkgsEngine channel;
+22 −0
Original line number Diff line number Diff line
@@ -17,6 +17,28 @@ let
        if [ -d '${flutter.sdk}/.git' ]; then
          ln -s '${flutter.sdk}/.git' "$out"
        fi

        # For iOS/macOS builds, *.xcframework/'s from the pre-built
        # artifacts are copied into each built app. However, the symlinkJoin
        # means that the *.xcframework's contain symlinks into the nix store,
        # which causes issues when actually running the apps.
        #
        # We'll fix this by only linking to an outer *.xcframework dir instead
        # of trying to symlinkJoin the files inside the *.xcframework.
        artifactsDir="$out/bin/cache/artifacts/engine"
        shopt -s globstar
        for file in "$artifactsDir"/**/*.xcframework/Info.plist; do
          # Get the unwrapped path from the Info.plist inside each .xcframework
          origFile="$(readlink -f "$file")"
          origFrameworkDir="$(dirname "$origFile")"

          # Remove the symlinkJoin .xcframework dir and replace it with a symlink
          # to the unwrapped .xcframework dir.
          frameworkDir="$(dirname "$file")"
          rm -r "$frameworkDir"
          ln -s "$origFrameworkDir" "$frameworkDir"
        done
        shopt -u globstar
      '';

      passthru = flutter.passthru // {
+1 −3
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
, extraCFlags ? [ ]
, extraLinkerFlags ? [ ]
, makeWrapper
, runCommandLocal
, writeShellScript
, wrapGAppsHook3
, git
@@ -39,7 +38,6 @@
, cmake
, ninja
, clang
, lndir
, symlinkJoin
}:

@@ -56,7 +54,7 @@ let
      };
    }));

  cacheDir = symlinkJoin rec {
  cacheDir = symlinkJoin {
    name = "flutter-cache-dir";
    paths = builtins.attrValues flutterPlatformArtifacts;
    postBuild = ''