about summary refs log tree commit diff
path: root/pkgs/build-support/flutter
diff options
context:
space:
mode:
authorhacker1024 <hacker1024@users.sourceforge.net>2023-04-15 03:18:56 +1000
committerhacker1024 <hacker1024@users.sourceforge.net>2023-04-15 03:18:56 +1000
commitfdce3f30c4bde2ed4f7bef3f65f5dfc2a673f0ff (patch)
treedef1152013acd2355e28de32487958060feeb2f2 /pkgs/build-support/flutter
parent62e50080f39560183c57aa184bf03e47a341444c (diff)
flutter.mkFlutterApp: Don't hash more unstable files
Files and directories such as .dart_tool, .flutter-plugins, .packages and .pub-cache/hosted/*/.cache will be happily regenerated by the SDK in an offline environment.

The patches being made to these files and directories to remove non-determinism were flawed: They did not handle cases where files only appeared in one run, or cases where tooling versions had an effect on the output.
Diffstat (limited to 'pkgs/build-support/flutter')
-rw-r--r--pkgs/build-support/flutter/default.nix28
1 files changed, 4 insertions, 24 deletions
diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix
index 58149525b476d..f83998f3f9f79 100644
--- a/pkgs/build-support/flutter/default.nix
+++ b/pkgs/build-support/flutter/default.nix
@@ -43,13 +43,9 @@ let
 
       RES="$TMP"
 
-      mkdir -p "$RES/f"
-
       # so we can use lock, diff yaml
       cp "pubspec.yaml" "$RES"
       cp "pubspec.lock" "$RES"
-      [[ -e .packages ]] && mv .packages "$RES/f"
-      mv .dart_tool .flutter-plugins .flutter-plugins-dependencies "$RES/f"
 
       # replace paths with placeholders
       find "$RES" -type f -exec sed -i \
@@ -57,30 +53,16 @@ let
         -e s,${flutter.unwrapped},${placeholder_flutter},g \
         {} +
 
-      remove_line_matching() {
-        replace_line_matching "$1" "$2" ""
-      }
-
-      replace_line_matching() {
-        sed "s|.*$2.*|$3|g" -r -i "$1"
-      }
-
       # nuke nondeterminism
 
-      # clientId is random
-      remove_line_matching "$RES/.flutter" clientId
-
       # deterministic git repos
       find "$RES" -iname .git -type d | while read -r repoGit; do
         make_deterministic_repo "$(dirname "$repoGit")"
       done
 
-      # dart _fetchedAt, etc
-      DART_DATE=$(date --date="@$SOURCE_DATE_EPOCH" -In | sed "s|,|.|g" | sed "s|+.*||g")
-      find "$RES/.pub-cache" -iname "*.json" -exec sed -r 's|.*_fetchedAt.*|    "_fetchedAt": "'"$DART_DATE"'",|g' -i {} +
-      replace_line_matching "$RES/f/.dart_tool/package_config.json" '"generated"' '"generated": "'"$DART_DATE"'",'
-      replace_line_matching "$RES/f/.flutter-plugins-dependencies" '"date_created"' '"date_created": "'"$DART_DATE"'",'
-      [[ -e "$RES/f/.packages" ]] && remove_line_matching "$RES/f/.packages" "Generated by pub"
+      # Impure Pub files
+      rm -rf "$RES"/.pub-cache/hosted/*/.cache # Not pinned by pubspec.lock
+      rm -f "$RES"/.pub-cache/README.md # May change with different Dart versions
 
       # nuke refs
       find "$RES" -type f -exec nuke-refs {} +
@@ -89,7 +71,7 @@ let
       tar --owner=0 --group=0 --numeric-owner --format=gnu \
           --sort=name --mtime="@$SOURCE_DATE_EPOCH" \
           -czf "$out" -C "$RES" \
-          pubspec.yaml pubspec.lock f .pub-cache
+          pubspec.yaml pubspec.lock .pub-cache
     '';
 
     GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt";
@@ -148,8 +130,6 @@ let
     fi
     diff -u pubspec.yaml "$HOME/pubspec.yaml"
 
-    mv -v $(find "$HOME/f" -type f) .
-
     runHook postConfigure
   '';