mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
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.
This commit is contained in:
parent
38e20a3242
commit
3771de8ae0
|
@ -19,6 +19,7 @@ args=()
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case $arg in
|
case $arg in
|
||||||
--system=*)
|
--system=*)
|
||||||
|
system="${arg#*=}"
|
||||||
systemArg="--system ${arg#*=}"
|
systemArg="--system ${arg#*=}"
|
||||||
;;
|
;;
|
||||||
--version-key=*)
|
--version-key=*)
|
||||||
|
@ -78,6 +79,26 @@ if [[ -z "$versionKey" ]]; then
|
||||||
versionKey=version
|
versionKey=version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Allow finding packages among flake outputs in repos using flake-compat.
|
||||||
|
pname=$(nix-instantiate $systemArg --eval --strict -A "$attr.name" || echo)
|
||||||
|
if [[ -z "$pname" ]]; then
|
||||||
|
if [[ -z "$system" ]]; then
|
||||||
|
system=$(nix-instantiate --eval -E 'builtins.currentSystem' | tr -d '"')
|
||||||
|
fi
|
||||||
|
|
||||||
|
pname=$(nix-instantiate $systemArg --eval --strict -A "packages.$system.$attr.name" || echo)
|
||||||
|
if [[ -n "$pname" ]]; then
|
||||||
|
attr="packages.$system.$attr"
|
||||||
|
else
|
||||||
|
pname=$(nix-instantiate $systemArg --eval --strict -A "legacyPackages.$system.$attr.name" || echo)
|
||||||
|
if [[ -n "$pname" ]]; then
|
||||||
|
attr="legacyPackages.$system.$attr"
|
||||||
|
else
|
||||||
|
die "Could not find attribute '$attr'!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z "$nixFile" ]]; then
|
if [[ -z "$nixFile" ]]; then
|
||||||
nixFile=$(nix-instantiate $systemArg --eval --strict -A "$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
|
nixFile=$(nix-instantiate $systemArg --eval --strict -A "$attr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
|
||||||
if [[ ! -f "$nixFile" ]]; then
|
if [[ ! -f "$nixFile" ]]; then
|
||||||
|
|
Loading…
Reference in a new issue