mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-17 06:06:13 +03:00
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.
This commit is contained in:
parent
62e50080f3
commit
fdce3f30c4
@ -21,7 +21,7 @@ flutter.mkFlutterApp rec {
|
||||
|
||||
passthru.helper = python3.pkgs.callPackage ./helper.nix { inherit src version meta; };
|
||||
|
||||
vendorHash = "sha256-1ast8pm9wrt9nqLt5MJ2LkiZivlm9d+qcKrz/d8VVmI=";
|
||||
vendorHash = "sha256-/WP6oN5avAILZd3SkC/jmsqNL+BxdQGUjNwsjLF9RB4=";
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace linux/CMakeLists.txt \
|
||||
|
@ -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
|
||||
'';
|
||||
|
||||
|
@ -7,7 +7,7 @@ flutter2.mkFlutterApp {
|
||||
pname = "firmware-updater";
|
||||
version = "unstable";
|
||||
|
||||
vendorHash = "sha256-QPLAMFL/enMfbmUZx6qQSswI/vxeWgjytRdoNxziQ18=";
|
||||
vendorHash = "sha256-Pj6CU2W5juk4YE8oq+v7Z8CzuSwpyA3YqscoWGDaI4o=";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "canonical";
|
||||
|
Loading…
Reference in New Issue
Block a user