lol

flet-client-flutter: adjusting the updater to handle the new cases

Signed-off-by: lucasew <lucas59356@gmail.com>

+52 -11
+1
pkgs/by-name/fl/flet-client-flutter/git_hashes.json
··· 1 + {}
+9 -11
pkgs/by-name/fl/flet-client-flutter/package.nix
··· 7 7 , makeWrapper 8 8 , mimalloc 9 9 , orc 10 - , yq 11 - , runCommand 10 + , python3 11 + , nix 12 12 , gitUpdater 13 + , nix-prefetch-git 13 14 , mpv-unwrapped 14 15 , libplacebo 15 16 , _experimental-update-script-combinators 16 - , flet-client-flutter 17 17 , fletTarget ? "linux" 18 18 }: 19 19 ··· 29 29 }; 30 30 31 31 sourceRoot = "${src.name}/client"; 32 + 33 + gitHashes = lib.importJSON ./git_hashes.json; 32 34 33 35 cmakeFlags = [ 34 36 "-DMIMALLOC_LIB=${mimalloc}/lib/mimalloc.o" ··· 59 61 ; 60 62 61 63 passthru = { 62 - pubspecSource = runCommand "pubspec.lock.json" { 63 - buildInputs = [ yq ]; 64 - inherit (flet-client-flutter) src; 65 - } '' 66 - cat $src/client/pubspec.lock | yq > $out 67 - ''; 68 - 69 64 updateScript = _experimental-update-script-combinators.sequence [ 70 65 (gitUpdater { rev-prefix = "v"; }) 71 - (_experimental-update-script-combinators.copyAttrOutputToFile "flet-client-flutter.pubspecSource" ./pubspec.lock.json) 66 + { 67 + command = ["env" "PATH=${lib.makeBinPath [(python3.withPackages (p: [p.pyyaml])) nix-prefetch-git nix]}" "python3" ./update-lockfiles.py ]; 68 + supportedFeatures = ["silent"]; 69 + } 72 70 ]; 73 71 }; 74 72
+42
pkgs/by-name/fl/flet-client-flutter/update-lockfiles.py
··· 1 + from argparse import ArgumentParser 2 + from pathlib import Path 3 + import json 4 + import subprocess 5 + import yaml 6 + 7 + THIS_FOLDER = Path(__file__).parent 8 + FLAKE_DIR = THIS_FOLDER 9 + while True: 10 + assert str(FLAKE_DIR) != '/' 11 + if (FLAKE_DIR / "flake.nix").exists(): 12 + break 13 + FLAKE_DIR = FLAKE_DIR.parent 14 + 15 + source = Path(subprocess.run(['nix-build', FLAKE_DIR, '-A', 'flet-client-flutter.src', '--no-out-link'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()) 16 + assert source.is_absolute() 17 + 18 + source_pubspec_lock = source / "client" / "pubspec.lock" 19 + 20 + output_pubspec = THIS_FOLDER / "pubspec.lock.json" 21 + output_git_hashes = THIS_FOLDER / "git_hashes.json" 22 + 23 + data = yaml.safe_load(source_pubspec_lock.open('r')) 24 + output_pubspec.write_text(json.dumps(data, indent=2) + "\n") 25 + 26 + output_data = {} 27 + 28 + def hash_git(package): 29 + print(package) 30 + resolved_ref = package['resolved-ref'] 31 + url = package['url'] 32 + full_output = subprocess.run(['nix-prefetch-git', '--url', url, '--rev', resolved_ref], stdout=subprocess.PIPE).stdout.decode('utf-8') 33 + json_output = json.loads(full_output) 34 + return json_output['hash'] 35 + 36 + for name, package in data['packages'].items(): 37 + if package['source'] != 'git': 38 + continue 39 + hash = hash_git(package['description']) 40 + output_data[name] = hash 41 + 42 + output_git_hashes.write_text(json.dumps(output_data, indent=2) + "\n")