flutter: Fetch artifacts with `flutter prefetch`

authored by hacker1024 and committed by Maciej Krüger 44030b7f de1d8091

+152 -448
+43
pkgs/development/compilers/flutter/artifacts/fetch-artifacts.nix
··· 1 + { lib 2 + , runCommand 3 + , cacert 4 + , unzip 5 + 6 + , platform 7 + , flutter 8 + , hash 9 + }: 10 + 11 + let 12 + platforms = [ 13 + "android" 14 + "ios" 15 + "web" 16 + "linux" 17 + "windows" 18 + "macos" 19 + "fuchsia" 20 + "universal" 21 + ]; 22 + in 23 + runCommand "flutter-artifacts-${platform}" 24 + { 25 + nativeBuildInputs = [ flutter unzip ]; 26 + 27 + NIX_FLUTTER_TOOLS_VM_OPTIONS = "--root-certs-file=${cacert}/etc/ssl/certs/ca-bundle.crt"; 28 + 29 + outputHash = hash; 30 + outputHashMode = "recursive"; 31 + outputHashAlgo = "sha256"; 32 + 33 + passthru = { 34 + inherit platform; 35 + }; 36 + } '' 37 + runHook preBuild 38 + 39 + mkdir -p "$out" 40 + HOME="$NIX_BUILD_TOP" FLUTTER_CACHE_DIR="$out" flutter precache -v '--${platform}' ${builtins.concatStringsSep " " (map (p: "'--no-${p}'") (lib.remove platform platforms))} 41 + 42 + runHook postBuild 43 + ''
+38
pkgs/development/compilers/flutter/artifacts/hashes.nix
··· 1 + # NOTICE: When updating these hashes, make sure that no additional platforms 2 + # have been added to the `flutter precache` CLI. If any have, they may be 3 + # included in every derivation, unless they are also added to the platform list 4 + # in fetch-artifacts.nix. 5 + # 6 + # The known arguments are as follows: 7 + # $ flutter precache --help --verbose 8 + # Usage: flutter precache [arguments] 9 + # -h, --help Print this usage information. 10 + # -a, --all-platforms Precache artifacts for all host platforms. 11 + # -f, --force Force re-downloading of artifacts. 12 + # --[no-]android Precache artifacts for Android development. 13 + # --[no-]android_gen_snapshot Precache gen_snapshot for Android development. 14 + # --[no-]android_maven Precache Gradle dependencies for Android development. 15 + # --[no-]android_internal_build Precache dependencies for internal Android development. 16 + # --[no-]ios Precache artifacts for iOS development. 17 + # --[no-]web Precache artifacts for web development. 18 + # --[no-]linux Precache artifacts for Linux desktop development. 19 + # --[no-]windows Precache artifacts for Windows desktop development. 20 + # --[no-]macos Precache artifacts for macOS desktop development. 21 + # --[no-]fuchsia Precache artifacts for Fuchsia development. 22 + # --[no-]universal Precache artifacts required for any development platform. 23 + # (defaults to on) 24 + # --[no-]flutter_runner Precache the flutter runner artifacts. 25 + # --[no-]use-unsigned-mac-binaries Precache the unsigned macOS binaries when available. 26 + 27 + { 28 + "3.13.8" = { 29 + android = "sha256-Uc36aBq8wQo2aEvjAPOoixZElWOE/GNRm2GUfhbwT3Y="; 30 + fuchsia = "sha256-eu0BERdz53CkSexbpu3KA7O6Q4g0s9SGD3t1Snsk3Fk="; 31 + ios = "sha256-QwkeGnutTVsm682CqxRtEd9rKUvN7zlAJcqkvAQYwao="; 32 + linux = "sha256-0gIOwux3YBdmcXgwICr8dpftj1CauaBUX8Rt5GG0WSs="; 33 + macos = "sha256-9WqCJQ37mcGc5tzfqQoY5CqHWHGTizjXf9p73bdnNWc="; 34 + universal = "sha256-wATt1UPjo/fh7RFO1vvcUAdo0dMAaaOUIuzYodsM0v0="; 35 + web = "sha256-DVXJOOFxv7tKt3d0NaYMexkphEcr7+gDFV67I6iAYa0="; 36 + windows = "sha256-s8fJtwQkuZaGXr6vrPiKfpwP/NfewbETwyp9ERGqHYI="; 37 + }; 38 + }
+10
pkgs/development/compilers/flutter/artifacts/overrides/linux.nix
··· 1 + { gtk3 2 + }: 3 + 4 + { buildInputs ? [ ] 5 + , ... 6 + }: 7 + 8 + { 9 + buildInputs = buildInputs ++ [ gtk3 ]; 10 + }
+21
pkgs/development/compilers/flutter/artifacts/prepare-artifacts.nix
··· 1 + { stdenv 2 + , lib 3 + , autoPatchelfHook 4 + , src 5 + }: 6 + 7 + stdenv.mkDerivation { 8 + inherit (src) name; 9 + inherit src; 10 + 11 + nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook; 12 + 13 + installPhase = '' 14 + runHook preInstall 15 + 16 + mkdir -p "$out/bin" 17 + cp -r . "$out/bin/cache" 18 + 19 + runHook postInstall 20 + ''; 21 + }
+1 -7
pkgs/development/compilers/flutter/default.nix
··· 55 55 buildFlutterApplication = callPackage ../../../build-support/flutter { 56 56 # Package a minimal version of Flutter that only uses Linux desktop release artifacts. 57 57 flutter = (wrapFlutter (mkCustomFlutter args)).override { 58 - supportsAndroid = false; 59 - includedEngineArtifacts = { 60 - common = [ "flutter_patched_sdk_product" ]; 61 - platform.linux = lib.optionals stdenv.hostPlatform.isLinux 62 - (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64")) 63 - (architecture: [ "release" ])); 64 - }; 58 + supportedTargetPlatforms = [ "universal" "linux" ]; 65 59 }; 66 60 }; 67 61 };
-243
pkgs/development/compilers/flutter/engine-artifacts/default.nix
··· 1 - { lib 2 - , stdenv 3 - , hostPlatform 4 - , engineVersion 5 - , fetchurl 6 - , fetchzip 7 - , autoPatchelfHook 8 - , gtk3 9 - , flutterVersion 10 - , unzip 11 - , stdenvNoCC 12 - }: 13 - 14 - let 15 - hashes = (import ./hashes.nix).${engineVersion} or 16 - (throw "There are no known artifact hashes for Flutter engine version ${engineVersion}."); 17 - noticeText = stdenvNoCC.mkDerivation (finalAttrs: { 18 - pname = "flutter-notice"; 19 - version = engineVersion; 20 - dontUnpack = true; 21 - src = fetchurl { 22 - pname = "flutter-sky_engine-LICENSE"; 23 - version = engineVersion; 24 - url = "https://raw.githubusercontent.com/flutter/engine/${engineVersion}/sky/packages/sky_engine/LICENSE"; 25 - sha256 = hashes.skyNotice; 26 - }; 27 - flutterNotice = fetchurl { 28 - pname = "flutter-LICENSE"; 29 - version = engineVersion; 30 - url = "https://raw.githubusercontent.com/flutter/flutter/${flutterVersion}/LICENSE"; 31 - sha256 = hashes.flutterNotice; 32 - }; 33 - installPhase = 34 - '' 35 - SRC_TEXT="$(cat $src)" 36 - FLUTTER_NOTICE_TEXT="$(cat $flutterNotice)" 37 - cat << EOF > $out 38 - This artifact is from the Flutter SDK's engine. 39 - This file carries third-party notices for its dependencies. 40 - See also other files, that have LICENSE in the name, in the artifact directory. 41 - 42 - Appendix 1/2: merged sky_engine LICENSE file (also found at ${finalAttrs.src.url}) 43 - $SRC_TEXT 44 - 45 - Appendix 2/2: Flutter license (also found at ${finalAttrs.flutterNotice.url}) 46 - $FLUTTER_NOTICE_TEXT 47 - EOF 48 - ''; 49 - }); 50 - artifacts = 51 - { 52 - common = { 53 - flutter_patched_sdk = { archive = "flutter_patched_sdk.zip"; }; 54 - flutter_patched_sdk_product = { archive = "flutter_patched_sdk_product.zip"; }; 55 - }; 56 - platform = { 57 - android = 58 - (lib.genAttrs 59 - [ "arm" "arm64" "x64" ] 60 - (arch: 61 - { 62 - base = [ 63 - { archive = "artifacts.zip"; } 64 - ]; 65 - variants = lib.genAttrs [ "profile" "release" ] 66 - (variant: [ 67 - { archive = "artifacts.zip"; } 68 - { subdirectory = true; archive = "${lib.toLower hostPlatform.uname.system}-x64.zip"; } 69 - ]); 70 - })) // 71 - { 72 - "x86" = { 73 - base = [ 74 - { archive = "artifacts.zip"; } 75 - ]; 76 - variants.jit-release = [ 77 - { archive = "artifacts.zip"; } 78 - ]; 79 - }; 80 - }; 81 - 82 - darwin = { 83 - "arm64" = { 84 - base = [ 85 - { archive = "artifacts.zip"; } 86 - { archive = "font-subset.zip"; } 87 - ]; 88 - variants = lib.genAttrs [ "profile" "release" ] 89 - (variant: [ 90 - { archive = "artifacts.zip"; } 91 - ]); 92 - }; 93 - "x64" = { 94 - base = [ 95 - { archive = "FlutterEmbedder.framework.zip"; } 96 - { archive = "FlutterMacOS.framework.zip"; } 97 - { archive = "artifacts.zip"; } 98 - { archive = "font-subset.zip"; } 99 - { archive = "gen_snapshot.zip"; } 100 - ]; 101 - variants.profile = [ 102 - { archive = "FlutterMacOS.framework.zip"; } 103 - { archive = "artifacts.zip"; } 104 - { archive = "gen_snapshot.zip"; } 105 - ]; 106 - variants.release = [ 107 - { archive = "FlutterMacOS.dSYM.zip"; } 108 - { archive = "FlutterMacOS.framework.zip"; } 109 - { archive = "artifacts.zip"; } 110 - { archive = "gen_snapshot.zip"; } 111 - ]; 112 - }; 113 - }; 114 - 115 - ios = 116 - (lib.genAttrs 117 - [ "" ] 118 - (arch: 119 - { 120 - base = [ 121 - { archive = "artifacts.zip"; } 122 - ]; 123 - variants.profile = [ 124 - { archive = "artifacts.zip"; } 125 - ]; 126 - variants.release = [ 127 - { archive = "artifacts.zip"; } 128 - { archive = "Flutter.dSYM.zip"; } 129 - ]; 130 - })); 131 - 132 - linux = lib.genAttrs 133 - [ "arm64" "x64" ] 134 - (arch: 135 - let 136 - linux-flutter-gtk = { 137 - archive = "linux-${arch}-flutter-gtk.zip"; 138 - buildInputs = [ gtk3 ]; 139 - }; 140 - in 141 - { 142 - base = [ 143 - ({ archive = "artifacts.zip"; } // lib.optionalAttrs (arch == "arm64") { 144 - # For some reason, the arm64 artifacts are missing shader code in Flutter < 3.10.0. 145 - postPatch = '' 146 - if [ ! -d shader_lib ]; then 147 - ln -s ${lib.findSingle 148 - (pkg: lib.getName pkg == "flutter-artifact-linux-x64-artifacts") 149 - (throw "Could not find the x64 artifact archive.") 150 - (throw "Could not find the correct x64 artifact archive.") 151 - artifactDerivations.platform.linux.x64.base 152 - }/shader_lib . 153 - fi 154 - ''; 155 - }) 156 - { archive = "font-subset.zip"; } 157 - (linux-flutter-gtk // { 158 - # https://github.com/flutter/flutter/commit/9d94a51b607600a39c14470c35c676eb3e30eed6 159 - variant = "debug"; 160 - }) 161 - ]; 162 - variants = lib.genAttrs [ "debug" "profile" "release" ] (variant: [ 163 - linux-flutter-gtk 164 - ]); 165 - }); 166 - }; 167 - }; 168 - 169 - mkArtifactDerivation = { platform ? null, variant ? null, subdirectory ? null, archive, ... }@args: 170 - let 171 - artifactDirectory = if platform == null then null else "${platform}${lib.optionalString (variant != null) "-${variant}"}"; 172 - archiveBasename = lib.removeSuffix ".${(lib.last (lib.splitString "." archive))}" archive; 173 - overrideUnpackCmd = builtins.elem archive [ "FlutterEmbedder.framework.zip" "FlutterMacOS.framework.zip" ]; 174 - in 175 - stdenv.mkDerivation ({ 176 - pname = "flutter-artifact${lib.optionalString (platform != null) "-${artifactDirectory}"}-${archiveBasename}"; 177 - version = engineVersion; 178 - 179 - nativeBuildInputs = [ unzip ] 180 - ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]; 181 - 182 - src = 183 - if overrideUnpackCmd then 184 - (fetchurl { 185 - url = "https://storage.googleapis.com/flutter_infra_release/flutter/${engineVersion}${lib.optionalString (platform != null) "/${artifactDirectory}"}/${archive}"; 186 - hash = (if artifactDirectory == null then hashes else hashes.${artifactDirectory}).${archive}; 187 - }) else 188 - (fetchzip { 189 - url = "https://storage.googleapis.com/flutter_infra_release/flutter/${engineVersion}${lib.optionalString (platform != null) "/${artifactDirectory}"}/${archive}"; 190 - stripRoot = false; 191 - hash = (if artifactDirectory == null then hashes else hashes.${artifactDirectory}).${archive}; 192 - }); 193 - 194 - sourceRoot = if overrideUnpackCmd then "." else null; 195 - unpackCmd = if overrideUnpackCmd then "unzip -o $src -d $out" else null; 196 - 197 - installPhase = 198 - let 199 - destination = "$out/${if subdirectory == true then archiveBasename else if subdirectory != null then subdirectory else "."}"; 200 - in 201 - '' 202 - # ship the notice near all artifacts. if the artifact directory is / multiple directories are nested in $src, link it there. If there isn't a directory, link it in root 203 - # this *isn't the same as the subdirectory variable above* 204 - DIR_CNT="$(echo */ | wc -w)" 205 - if [[ "$DIR_CNT" == 0 ]]; then 206 - ln -s ${noticeText} LICENSE.README 207 - else 208 - for dir in */ 209 - do 210 - ln -s ${noticeText} "$dir/LICENSE.README" 211 - done 212 - fi 213 - mkdir -p "${destination}" 214 - cp -r . "${destination}" 215 - ''; 216 - } // args); 217 - 218 - artifactDerivations = { 219 - common = builtins.mapAttrs (name: mkArtifactDerivation) artifacts.common; 220 - platform = 221 - builtins.mapAttrs 222 - (os: architectures: 223 - builtins.mapAttrs 224 - (architecture: variants: { 225 - base = map 226 - (args: mkArtifactDerivation ({ 227 - platform = "${os}${lib.optionalString (architecture != "") "-${architecture}"}"; 228 - } // args)) 229 - variants.base; 230 - variants = builtins.mapAttrs 231 - (variant: variantArtifacts: map 232 - (args: mkArtifactDerivation ({ 233 - platform = "${os}${lib.optionalString (architecture != "") "-${architecture}"}"; 234 - inherit variant; 235 - } // args)) 236 - variantArtifacts) 237 - variants.variants; 238 - }) 239 - architectures) 240 - artifacts.platform; 241 - }; 242 - in 243 - artifactDerivations
-118
pkgs/development/compilers/flutter/engine-artifacts/hashes.nix
··· 1 - { 2 - "767d8c75e898091b925519803830fc2721658d07" = { 3 - skyNotice = "sha256-bJMktK26wC9fVzdhLNcTHqOg5sHRZ535LB5u5dgwjlY="; 4 - flutterNotice = "sha256-pZjblLYpD/vhC17PkRBXtqlDNRxyf92p5fKJHWhwCiA="; 5 - android-arm = { 6 - "artifacts.zip" = "sha256-pnUDY2sUN2r/LrivyNkfTUpQC90GKOI6Ya+0lgIz+c0="; 7 - }; 8 - android-arm-profile = { 9 - "artifacts.zip" = "sha256-/kDNI+no4u2Ri/FqqsQEp2iEqifULYGqzz8w0G4pzCM="; 10 - "linux-x64.zip" = "sha256-fUfaDJIo1VcdJHcd0jO98Az3OdNQ+JtA5Mp6nQVVU4E="; 11 - "darwin-x64.zip" = "sha256-J7vDD5VEsgnWmbI8acM3vQwrnrqcfMaCijiItDfniLY="; 12 - }; 13 - android-arm-release = { 14 - "artifacts.zip" = "sha256-tVAFHHG8A8vlgQu6l6ybdfm6OmBf2vrYf3PZByWvs08="; 15 - "linux-x64.zip" = "sha256-lrejG7zpUBox9kPvs1uPM/lyR1d/SAc1w+c6kcqghHI="; 16 - "darwin-x64.zip" = "sha256-8lKOsqLgbnuoCR87v84dn8V3PRzl1+maWFIHopiGvbc="; 17 - }; 18 - android-arm64 = { 19 - "artifacts.zip" = "sha256-rcU2mX0nP1ot+6DU+uxvILUOAuwTPGH23UQ6riBs0d4="; 20 - }; 21 - android-arm64-profile = { 22 - "artifacts.zip" = "sha256-x4TEJWi3c6mEPGh+3l4PtRqsg4Tq7mxHtGz+4MqwzPw="; 23 - "linux-x64.zip" = "sha256-PsDKOq3DXaNeNtaFtDQJ9JIEESXBHm8XHHpOw2u1cGg="; 24 - "darwin-x64.zip" = "sha256-K4W1CEBOlZVsHjuhvKCUZWv45VSohRd23vviaLqMNjQ="; 25 - }; 26 - android-arm64-release = { 27 - "artifacts.zip" = "sha256-w+J4sNhYoj44IiHpZ0BkemCYlE9wOTvWL57Y8RCstkI="; 28 - "linux-x64.zip" = "sha256-MJsmck27V14/f0IAT6b/R47p8/eCMX9Nn//PEAbEeOY="; 29 - "darwin-x64.zip" = "sha256-xXa5GFatJPiwBANqeWUpAdM9gibD4xH85aI6YpJrcpI="; 30 - }; 31 - android-x64 = { 32 - "artifacts.zip" = "sha256-doNUwEJkwncHPIf2c8xOZByUU8dmogtWlc6q7n7ElDY="; 33 - }; 34 - android-x64-profile = { 35 - "artifacts.zip" = "sha256-N3AjdHdzj4s6v3f3Gf6n/1Xk0W7xFQP70SneCNlj2sk="; 36 - "linux-x64.zip" = "sha256-pNn75iZqLwOGO3ZmymmrSasDPMmDWwp9ZWBv9Xti4cU="; 37 - "darwin-x64.zip" = "sha256-6O4lA/4wZ91ODUUYHe4HpjvraAEbhHiehBmf3sT37Dc="; 38 - }; 39 - android-x64-release = { 40 - "artifacts.zip" = "sha256-odDS/m8fgSA24EYt+W2sEDmOlPO17FZxxomWuYUHmns="; 41 - "linux-x64.zip" = "sha256-sVQYmu0KaPADlL59XZc26Ks+TbmaJxRGPiJKlWxUhRA="; 42 - "darwin-x64.zip" = "sha256-dep/CmBIDkvqYKQPWMCDTDbFhVvOk6N7JAF8v3dr/P8="; 43 - }; 44 - android-x86 = { 45 - "artifacts.zip" = "sha256-MzTFQ0XPtd9OXvKfM98bwpxN/xfEcXox24gn/4aS/Do="; 46 - }; 47 - android-x86-jit-release = { 48 - "artifacts.zip" = "sha256-cUsBqJxOOluwnYEFzdtZof8c4Vp1D81HkEEH8aRGLyY="; 49 - }; 50 - darwin-arm64 = { 51 - "artifacts.zip" = "sha256-df+rmN0RqLM7MgEKjTcybMY0bFYCB1jsTvaVE1J0BzY="; 52 - "font-subset.zip" = "sha256-hJ5fECxN4oZX6E9ivzSDGejNSj56t2SKccbyfozXxps="; 53 - }; 54 - darwin-arm64-profile = { 55 - "artifacts.zip" = "sha256-EaXOr998zE4cG5G5FRtsDGt3jjg1GjkRGE/ZDD3Coto="; 56 - }; 57 - darwin-arm64-release = { 58 - "artifacts.zip" = "sha256-1XMoM8jDRoUSPMauKD5lsgC25B7Htod8wYouDKSEGJY="; 59 - }; 60 - darwin-x64 = { 61 - "FlutterEmbedder.framework.zip" = "sha256-vzvt0pwo1HbIxxym/jn2Y+1+Iqm/Gw2TfymEcuUHIXQ="; 62 - "FlutterMacOS.framework.zip" = "sha256-cMTCULaVOKDq8VrqCmZLo0IPBve0GSh0K2yvtdCvX8c="; 63 - "artifacts.zip" = "sha256-8BViZUz4b0XurQJM+FCU2toONKmhajabCc66gBUVGgY="; 64 - "font-subset.zip" = "sha256-VgqNdUmvTbSedQtJNT+Eq90GWS4hXCDCBDBjno6s1dk="; 65 - "gen_snapshot.zip" = "sha256-4O0ZfKt96x8/Jwh8DgBoPFiv84Tqf9tR/f0PVRJlJiQ="; 66 - }; 67 - darwin-x64-profile = { 68 - "FlutterMacOS.framework.zip" = "sha256-IrXK0Mjllic3OKaYKKpAE9gPIceTO32hGqgxGR66QmY="; 69 - "artifacts.zip" = "sha256-IHllbxwRMrEWA1MI0DRCYYRzYAdQIL8B9b5rZHsOvjc="; 70 - "gen_snapshot.zip" = "sha256-bPI6pHrWQR1X7CzytbJA90TYe3cg1yN+9v7JtsCCrbQ="; 71 - }; 72 - darwin-x64-release = { 73 - "FlutterMacOS.dSYM.zip" = "sha256-HjU8sLPwvOwO3LP7krpZZW6/t3sN3rX2frFnBp1Kk0I="; 74 - "FlutterMacOS.framework.zip" = "sha256-GuTWojZFdSEeOiSYxH8XGSWsxcrkUpnXA61B0NpDa5A="; 75 - "artifacts.zip" = "sha256-tQCm1HHrhffNz9a0lNIHXLBqFMbT4QiaibKvRKuuhJ4="; 76 - "gen_snapshot.zip" = "sha256-0na+yx0Nxe/FuHVZqhgbRniZLInShoKE3USaJg0829o="; 77 - }; 78 - "flutter_patched_sdk.zip" = "sha256-AVjXLND3nJAaGyBAhytBRUvbkJtwZEcndQSrq+D2c08="; 79 - "flutter_patched_sdk_product.zip" = "sha256-31qgieDI897sXtEf8ok2SdFgrlN57bwhT3FUfdofZi0="; 80 - ios = { 81 - "artifacts.zip" = "sha256-RicBTTBX5aIQwfcolDrKe0MVG9uTp56RYMWgR75AVEw="; 82 - }; 83 - ios-profile = { 84 - "artifacts.zip" = "sha256-6EXHvy36K+rRGpjt0GL/DyuOhpAGeaOrZAZvPZuLyys="; 85 - }; 86 - ios-release = { 87 - "Flutter.dSYM.zip" = "sha256-zYqlX4QhxnDb9LasMcBcPO/+30LCfVbwC+z+wZiiEqk="; 88 - "artifacts.zip" = "sha256-DVpynf2LxU6CPC1BPQbi8OStcIwJKX55rDSWNiJ4KNk="; 89 - }; 90 - linux-arm64 = { 91 - "artifacts.zip" = "sha256-djesma+IqQZgGlxQj4Gv6hAkQhQKQp7Gsa1I4hksqNc="; 92 - "font-subset.zip" = "sha256-Wo11dks0uhLI2nu+9QJ7aLmvfsPcuqvcmquak4qv5XM="; 93 - }; 94 - linux-arm64-debug = { 95 - "linux-arm64-flutter-gtk.zip" = "sha256-6T2Ycxe3GTVnFGfBFfXLZwPklIndQ6hojnCSnMeXJso="; 96 - }; 97 - linux-arm64-profile = { 98 - "linux-arm64-flutter-gtk.zip" = "sha256-ycInFHuRu7r+50GsoFR4v/rIRiAQaQ9zFemd2d9AnpQ="; 99 - }; 100 - linux-arm64-release = { 101 - "linux-arm64-flutter-gtk.zip" = "sha256-J60MU8pHDVL9DyX5A3YdCRkKXnTgvALhHiEzYiPSSuA="; 102 - }; 103 - linux-x64 = { 104 - "artifacts.zip" = "sha256-ZUMRJ0dzaeRQUYy5S7gDLWa3w9CVhNPORN9l+lwxAMs="; 105 - "font-subset.zip" = "sha256-pmtHAgIj5tXzUsDrrxB5JwfLDNzMCqouUCOyYN5BOEQ="; 106 - }; 107 - linux-x64-debug = { 108 - "linux-x64-flutter-gtk.zip" = "sha256-otmghZAiUlpLYfFaWd18UWlfctKcYsMRBMP78ZyBj/E="; 109 - }; 110 - linux-x64-profile = { 111 - "linux-x64-flutter-gtk.zip" = "sha256-bT6xMYlwTB9JOV1790cJqTSEXYstdI4sZCQzFzcpa5s="; 112 - }; 113 - linux-x64-release = { 114 - "linux-x64-flutter-gtk.zip" = "sha256-E8Eogr0nD7yaxjuoNhpvF4tTx9N53y3iOkI71Eqx5Ko="; 115 - }; 116 - }; 117 - } 118 -
+1 -1
pkgs/development/compilers/flutter/sdk-symlink.nix
··· 6 6 self = 7 7 symlinkJoin { 8 8 name = "${flutter.name}-sdk-links"; 9 - paths = [ flutter flutter.sdk ]; 9 + paths = [ flutter flutter.cacheDir flutter.sdk ]; 10 10 11 11 nativeBuildInputs = [ makeWrapper ]; 12 12 postBuild = ''
+38 -79
pkgs/development/compilers/flutter/wrapper.nix
··· 3 3 , darwin 4 4 , callPackage 5 5 , flutter 6 - , supportsLinuxDesktop ? stdenv.hostPlatform.isLinux 7 - , supportsAndroid ? (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isDarwin) 8 - , supportsDarwin ? stdenv.hostPlatform.isDarwin 9 - , supportsIOS ? stdenv.hostPlatform.isDarwin 10 - , includedEngineArtifacts ? { 11 - common = [ 12 - "flutter_patched_sdk" 13 - "flutter_patched_sdk_product" 14 - ]; 15 - platform = { 16 - android = lib.optionalAttrs supportsAndroid 17 - ((lib.genAttrs [ "arm" "arm64" "x64" ] (architecture: [ "profile" "release" ])) // { x86 = [ "jit-release" ]; }); 18 - darwin = lib.optionalAttrs supportsDarwin 19 - ((lib.genAttrs [ "arm64" "x64" ] (architecture: [ "profile" "release" ]))); 20 - ios = lib.optionalAttrs supportsIOS 21 - ((lib.genAttrs [ "" ] (architecture: [ "profile" "release" ]))); 22 - linux = lib.optionalAttrs supportsLinuxDesktop 23 - (lib.genAttrs ((lib.optional stdenv.hostPlatform.isx86_64 "x64") ++ (lib.optional stdenv.hostPlatform.isAarch64 "arm64")) 24 - (architecture: [ "debug" "profile" "release" ])); 25 - }; 26 - } 6 + , supportedTargetPlatforms ? [ 7 + "universal" 8 + "web" 9 + ] 10 + ++ lib.optional stdenv.hostPlatform.isLinux "linux" 11 + ++ lib.optional (stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isDarwin) "android" 12 + ++ lib.optionals stdenv.hostPlatform.isDarwin [ "macos" "ios" ] 13 + , artifactHashes ? (import ./artifacts/hashes.nix).${flutter.version} 27 14 , extraPkgConfigPackages ? [ ] 28 15 , extraLibraries ? [ ] 29 16 , extraIncludes ? [ ] ··· 57 44 }: 58 45 59 46 let 60 - engineArtifacts = callPackage ./engine-artifacts { 61 - inherit (flutter) engineVersion; 62 - flutterVersion = flutter.version; 63 - }; 64 - mkCommonArtifactLinkCommand = { artifact }: 65 - '' 66 - mkdir -p $out/artifacts/engine/common 67 - lndir -silent ${artifact} $out/artifacts/engine/common 68 - ''; 69 - mkPlatformArtifactLinkCommand = { artifact, os, architecture, variant ? null }: 70 - let 71 - artifactDirectory = "${os}-${architecture}${lib.optionalString (variant != null) "-${variant}"}"; 72 - in 73 - '' 74 - mkdir -p $out/artifacts/engine/${artifactDirectory} 75 - lndir -silent ${artifact} $out/artifacts/engine/${artifactDirectory} 76 - ''; 77 - engineArtifactDirectory = 78 - runCommandLocal "flutter-engine-artifacts-${flutter.version}" { nativeBuildInputs = [ lndir ]; } 79 - ( 80 - builtins.concatStringsSep "\n" 81 - ((map 82 - (name: mkCommonArtifactLinkCommand { 83 - artifact = engineArtifacts.common.${name}; 84 - }) 85 - (includedEngineArtifacts.common or [ ])) ++ 86 - (builtins.foldl' 87 - (commands: os: commands ++ 88 - (builtins.foldl' 89 - (commands: architecture: commands ++ 90 - (builtins.foldl' 91 - (commands: variant: commands ++ 92 - (map 93 - (artifact: mkPlatformArtifactLinkCommand { 94 - inherit artifact os architecture variant; 95 - }) 96 - engineArtifacts.platform.${os}.${architecture}.variants.${variant})) 97 - (map 98 - (artifact: mkPlatformArtifactLinkCommand { 99 - inherit artifact os architecture; 100 - }) 101 - engineArtifacts.platform.${os}.${architecture}.base) 102 - includedEngineArtifacts.platform.${os}.${architecture})) 103 - [ ] 104 - (builtins.attrNames includedEngineArtifacts.platform.${os}))) 105 - [ ] 106 - (builtins.attrNames (includedEngineArtifacts.platform or { })))) 107 - ); 47 + supportsLinuxDesktopTarget = builtins.elem "linux" supportedTargetPlatforms; 48 + 49 + mkPlatformArtifacts = platform: 50 + (callPackage ./artifacts/prepare-artifacts.nix { 51 + src = callPackage ./artifacts/fetch-artifacts.nix { 52 + inherit platform; 53 + # Use a version of Flutter with just enough capabilities to download 54 + # artifacts. 55 + flutter = callPackage ./wrapper.nix { 56 + inherit flutter; 57 + supportedTargetPlatforms = [ ]; 58 + }; 59 + hash = artifactHashes.${platform} or ""; 60 + }; 61 + }).overrideAttrs ( 62 + if builtins.pathExists ./artifacts/overrides/${platform}.nix 63 + then callPackage ./artifacts/overrides/${platform}.nix { } 64 + else ({ ... }: { }) 65 + ); 108 66 109 67 cacheDir = symlinkJoin { 110 68 name = "flutter-cache-dir"; 111 - paths = [ 112 - engineArtifactDirectory 113 - "${flutter}/bin/cache" 114 - ]; 69 + paths = map mkPlatformArtifacts supportedTargetPlatforms; 70 + postBuild = '' 71 + mkdir -p "$out/bin/cache" 72 + ln -s '${flutter}/bin/cache/dart-sdk' "$out/bin/cache" 73 + ''; 115 74 }; 116 75 117 76 # By default, Flutter stores downloaded files (such as the Pub cache) in the SDK directory. ··· 120 79 # We do not patch it since the script doesn't require engine artifacts(which are the only thing not added by the unwrapped derivation), so it shouldn't fail, and patching it will just be harder to maintain. 121 80 immutableFlutter = writeShellScript "flutter_immutable" '' 122 81 export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} 123 - export FLUTTER_CACHE_DIR=''${FLUTTER_CACHE_DIR:-'${cacheDir}'} 82 + export FLUTTER_CACHE_DIR=''${FLUTTER_CACHE_DIR:-'${cacheDir}/bin/cache'} 124 83 ${flutter}/bin/flutter "$@" 125 84 ''; 126 85 ··· 128 87 tools = [ git which ]; 129 88 130 89 # Libraries that Flutter apps depend on at runtime. 131 - appRuntimeDeps = lib.optionals supportsLinuxDesktop [ 90 + appRuntimeDeps = lib.optionals supportsLinuxDesktopTarget [ 132 91 atk 133 92 cairo 134 93 gdk-pixbuf ··· 152 111 153 112 # Some header files and libraries are not properly located by the Flutter SDK. 154 113 # They must be manually included. 155 - appStaticBuildDeps = (lib.optionals supportsLinuxDesktop [ libX11 xorgproto zlib ]) ++ extraLibraries; 114 + appStaticBuildDeps = (lib.optionals supportsLinuxDesktopTarget [ libX11 xorgproto zlib ]) ++ extraLibraries; 156 115 157 116 # Tools used by the Flutter SDK to compile applications. 158 - buildTools = lib.optionals supportsLinuxDesktop [ 117 + buildTools = lib.optionals supportsLinuxDesktopTarget [ 159 118 pkg-config 160 119 cmake 161 120 ninja ··· 174 133 175 134 nativeBuildInputs = [ makeWrapper ] 176 135 ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.DarwinTools ] 177 - ++ lib.optionals supportsLinuxDesktop [ glib wrapGAppsHook ]; 136 + ++ lib.optionals supportsLinuxDesktopTarget [ glib wrapGAppsHook ]; 178 137 179 138 passthru = flutter.passthru // { 180 139 inherit (flutter) version; 181 140 unwrapped = flutter; 182 - inherit engineArtifacts; 141 + inherit cacheDir; 183 142 }; 184 143 185 144 dontUnpack = true;