Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

common-updater-scripts: Support attribute lookup in flake

In flakes, packages are not exposed directly but instead they are declared
inside “packages” or “legacyPackages” output under their host platform.
flake-compat reflects this.

Let’s look for an attribute also in these outputs if the direct lookup fails.

+21
+21
pkgs/common-updater/scripts/update-source-version
··· 19 19 for arg in "$@"; do 20 20 case $arg in 21 21 --system=*) 22 + system="${arg#*=}" 22 23 systemArg="--system ${arg#*=}" 23 24 ;; 24 25 --version-key=*) ··· 76 77 77 78 if [[ -z "$versionKey" ]]; then 78 79 versionKey=version 80 + fi 81 + 82 + # Allow finding packages among flake outputs in repos using flake-compat. 83 + pname=$(nix-instantiate $systemArg --eval --strict -A "$attr.name" || echo) 84 + if [[ -z "$pname" ]]; then 85 + if [[ -z "$system" ]]; then 86 + system=$(nix-instantiate --eval -E 'builtins.currentSystem' | tr -d '"') 87 + fi 88 + 89 + pname=$(nix-instantiate $systemArg --eval --strict -A "packages.$system.$attr.name" || echo) 90 + if [[ -n "$pname" ]]; then 91 + attr="packages.$system.$attr" 92 + else 93 + pname=$(nix-instantiate $systemArg --eval --strict -A "legacyPackages.$system.$attr.name" || echo) 94 + if [[ -n "$pname" ]]; then 95 + attr="legacyPackages.$system.$attr" 96 + else 97 + die "Could not find attribute '$attr'!" 98 + fi 99 + fi 79 100 fi 80 101 81 102 if [[ -z "$nixFile" ]]; then