Skip to content

Commit

Permalink
flutter: Rename platform to flutterPlatform
Browse files Browse the repository at this point in the history
This helps avoid the ambiguity between Flutter platforms like Linux, IOS, and Android and platforms like linux-x64
  • Loading branch information
FlafyDev committed Jan 10, 2024
1 parent dc1bb8c commit 579e013
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
, cacert
, unzip

, platform
, flutterPlatform
, flutter
, hash
}:

let
platforms = [
flutterPlatforms = [
"android"
"ios"
"web"
Expand All @@ -24,10 +24,10 @@ let
flutter' = flutter.override {
# Use a version of Flutter with just enough capabilities to download
# artifacts.
supportedTargetPlatforms = [ ];
supportedTargetFlutterPlatforms = [ ];
};
in
runCommand "flutter-artifacts-${platform}"
runCommand "flutter-artifacts-${flutterPlatform}"
{
nativeBuildInputs = [ xorg.lndir flutter' unzip ];

Expand All @@ -38,15 +38,15 @@ runCommand "flutter-artifacts-${platform}"
outputHashAlgo = "sha256";

passthru = {
inherit platform;
inherit flutterPlatform;
};
} ''
export FLUTTER_ROOT="$NIX_BUILD_TOP"
lndir -silent '${flutter'}' "$FLUTTER_ROOT"
rm -rf "$FLUTTER_ROOT/bin/cache"
mkdir "$FLUTTER_ROOT/bin/cache"
HOME="$(mktemp -d)" flutter precache -v '--${platform}' ${builtins.concatStringsSep " " (map (p: "'--no-${p}'") (lib.remove platform platforms))}
HOME="$(mktemp -d)" flutter precache -v '--${flutterPlatform}' ${builtins.concatStringsSep " " (map (p: "'--no-${p}'") (lib.remove flutterPlatform flutterPlatforms))}
rm -rf "$FLUTTER_ROOT/bin/cache/lockfile"
find "$FLUTTER_ROOT" -type l -lname '${flutter'}/*' -delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
runHook postInstall
'';
}).overrideAttrs (
if builtins.pathExists ./overrides/${src.platform}.nix
then callPackage ./overrides/${src.platform}.nix { }
if builtins.pathExists ./overrides/${src.flutterPlatform}.nix
then callPackage ./overrides/${src.flutterPlatform}.nix { }
else ({ ... }: { })
)
2 changes: 1 addition & 1 deletion pkgs/development/compilers/flutter/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let
buildFlutterApplication = callPackage ../../../build-support/flutter {
# Package a minimal version of Flutter that only uses Linux desktop release artifacts.
flutter = (wrapFlutter (mkCustomFlutter args)).override {
supportedTargetPlatforms = [ "universal" "linux" ];
supportedTargetFlutterPlatforms = [ "universal" "linux" ];
};
};
};
Expand Down
14 changes: 7 additions & 7 deletions pkgs/development/compilers/flutter/wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
, darwin
, callPackage
, flutter
, supportedTargetPlatforms ? [
, supportedTargetFlutterPlatforms ? [
"universal"
"web"
]
Expand Down Expand Up @@ -44,25 +44,25 @@
}:

let
supportsLinuxDesktopTarget = builtins.elem "linux" supportedTargetPlatforms;
supportsLinuxDesktopTarget = builtins.elem "linux" supportedTargetFlutterPlatforms;

platformArtifacts = lib.genAttrs supportedTargetPlatforms (platform:
flutterPlatformArtifacts = lib.genAttrs supportedTargetFlutterPlatforms (flutterPlatform:
(callPackage ./artifacts/prepare-artifacts.nix {
src = callPackage ./artifacts/fetch-artifacts.nix {
inherit platform;
inherit flutterPlatform;
flutter = callPackage ./wrapper.nix { inherit flutter; };
hash = artifactHashes.${platform}.${stdenv.hostPlatform.system} or "";
hash = artifactHashes.${flutterPlatform}.${stdenv.hostPlatform.system} or "";
};
}));

cacheDir = symlinkJoin rec {
name = "flutter-cache-dir";
paths = builtins.attrValues platformArtifacts;
paths = builtins.attrValues flutterPlatformArtifacts;
postBuild = ''
mkdir -p "$out/bin/cache"
ln -s '${flutter}/bin/cache/dart-sdk' "$out/bin/cache"
'';
passthru.platform = platformArtifacts;
passthru.flutterPlatform = flutterPlatformArtifacts;
};

# By default, Flutter stores downloaded files (such as the Pub cache) in the SDK directory.
Expand Down

0 comments on commit 579e013

Please sign in to comment.