diff --git a/pkgs/by-name/en/ente-auth/fetch-git-hashes.py b/pkgs/by-name/en/ente-auth/fetch-git-hashes.py new file mode 100755 index 000000000000..ff666a672370 --- /dev/null +++ b/pkgs/by-name/en/ente-auth/fetch-git-hashes.py @@ -0,0 +1,46 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i python3 -p nix-prefetch-git + +from dataclasses import dataclass +import json +import subprocess + + +@dataclass +class GitDependency: + name: str + url: str + revision: str + + +def get_git_deps(lock_data): + for name, data in lock_data["packages"].items(): + if data["source"] == "git": + desc = data["description"] + yield GitDependency( + name=name, + url=desc["url"], + revision=desc["resolved-ref"], + ) + + +def nix_prefetch_git(url: str, rev: str): + result = subprocess.run( + ["nix-prefetch-git", url, rev], + check=True, + text=True, + stdout=subprocess.PIPE, + ) + return json.loads(result.stdout) + + +if __name__ == "__main__": + with open("pubspec.lock.json") as lock_file: + lock_data = json.load(lock_file) + git_hashes = {} + for dep in get_git_deps(lock_data): + data = nix_prefetch_git(dep.url, dep.revision) + git_hashes[dep.name] = data["hash"] + with open("git-hashes.json", "w") as output_file: + json.dump(git_hashes, output_file, indent=2) + output_file.write("\n") diff --git a/pkgs/by-name/en/ente-auth/git-hashes.json b/pkgs/by-name/en/ente-auth/git-hashes.json new file mode 100644 index 000000000000..c08a0a3afac1 --- /dev/null +++ b/pkgs/by-name/en/ente-auth/git-hashes.json @@ -0,0 +1,7 @@ +{ + "ente_crypto_dart": "sha256-xBBK9BdXh4+OTj+Jkf3zh5sMZjXtvhyuE1R5LFE8iTY=", + "figma_squircle": "sha256-FLjABaJzrK3H5svbRb6306FxD5L6dMfddFXpXpYgH3s=", + "flutter_local_authentication": "sha256-r50jr+81ho+7q2PWHLf4VnvNJmhiARZ3s4HUpThCgc0=", + "flutter_secure_storage_linux": "sha256-Rp+b6ZRH7F5AnM5UvYzfVjprXkpeeA7V6Ep/oYqDeiM=", + "sqflite": "sha256-+XTVtkFJ94VifwnutvUuAqqiyWwrcEiZ3Uz0H4D9zWA=" +} diff --git a/pkgs/by-name/en/ente-auth/package.nix b/pkgs/by-name/en/ente-auth/package.nix index 445c6e320808..7a2e10c6b6ce 100644 --- a/pkgs/by-name/en/ente-auth/package.nix +++ b/pkgs/by-name/en/ente-auth/package.nix @@ -30,6 +30,7 @@ flutter324.buildFlutterApplication rec { sourceRoot = "${src.name}/auth"; pubspecLock = lib.importJSON ./pubspec.lock.json; + gitHashes = lib.importJSON ./git-hashes.json; patches = [ # Disable update notifications and auto-update functionality @@ -41,14 +42,6 @@ flutter324.buildFlutterApplication rec { ln -s ${simple-icons} assets/simple-icons ''; - gitHashes = { - ente_crypto_dart = "sha256-xBBK9BdXh4+OTj+Jkf3zh5sMZjXtvhyuE1R5LFE8iTY="; - flutter_local_authentication = "sha256-r50jr+81ho+7q2PWHLf4VnvNJmhiARZ3s4HUpThCgc0="; - flutter_secure_storage_linux = "sha256-Rp+b6ZRH7F5AnM5UvYzfVjprXkpeeA7V6Ep/oYqDeiM="; - sqflite = "sha256-+XTVtkFJ94VifwnutvUuAqqiyWwrcEiZ3Uz0H4D9zWA="; - figma_squircle = "sha256-FLjABaJzrK3H5svbRb6306FxD5L6dMfddFXpXpYgH3s="; - }; - nativeBuildInputs = [ copyDesktopItems makeWrapper diff --git a/pkgs/by-name/en/ente-auth/update.sh b/pkgs/by-name/en/ente-auth/update.sh index 7f79ffae58f4..ed5d30529b60 100755 --- a/pkgs/by-name/en/ente-auth/update.sh +++ b/pkgs/by-name/en/ente-auth/update.sh @@ -19,16 +19,23 @@ echo "Updating to $short_version" # Subtree needed for lockfile and icons auth_tree="$(gh-curl "https://api.github.com/repos/ente-io/ente/git/trees/$version" | gojq '.tree[] | select(.path == "auth") | .url' --raw-output)" +pushd "$pkg_dir" + # Get lockfile, filter out incompatible sqlite dependency and convert to JSON echo "Updating lockfile" pubspec_lock="$(gh-curl "$auth_tree" | gojq '.tree[] | select(.path == "pubspec.lock") | .url' --raw-output)" -gh-curl "$pubspec_lock" | gojq '.content | @base64d' --raw-output | gojq --yaml-input 'del(.packages.sqlite3_flutter_libs)' > "$pkg_dir/pubspec.lock.json" +gh-curl "$pubspec_lock" | gojq '.content | @base64d' --raw-output | gojq --yaml-input 'del(.packages.sqlite3_flutter_libs)' > pubspec.lock.json + +echo "Updating git hashes" +./fetch-git-hashes.py # Get rev and hash of simple-icons submodule echo "Updating icons" assets_tree="$(gh-curl "$auth_tree" | gojq '.tree[] | select(.path == "assets") | .url' --raw-output)" simple_icons_rev="$(gh-curl "$assets_tree" | gojq '.tree[] | select(.path == "simple-icons") | .sha' --raw-output)" -nix-prefetch-github --rev "$simple_icons_rev" simple-icons simple-icons > "$pkg_dir/simple-icons.json" +nix-prefetch-github --rev "$simple_icons_rev" simple-icons simple-icons > simple-icons.json + +popd # Update package version and hash echo "Updating package source"