sourcehut: make script work with non-python modules

Signed-off-by: Christoph Heiss <christoph@c8h4.io>

+15 -4
+15 -4
pkgs/applications/version-management/sourcehut/update.sh
··· 7 7 tmp=$(mktemp -d) 8 8 trap 'rm -rf "$tmp"' EXIT 9 9 10 + attr_path() { 11 + case "$1" in 12 + pagessrht) printf "sourcehut.$1";; 13 + *) printf "sourcehut.python.pkgs.$1";; 14 + esac 15 + } 16 + 10 17 default() { 11 - (cd "$root" && nix-instantiate --eval --strict -A "sourcehut.python.pkgs.$1.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/') 18 + local p="$(attr_path "$1")" 19 + (cd "$root" && nix-instantiate --eval --strict -A $p.meta.position | sed -re 's/^"(.*):[0-9]+"$/\1/') 12 20 } 13 21 14 22 version() { 15 - (cd "$root" && nix-instantiate --eval --strict -A "sourcehut.python.pkgs.$1.version" | tr -d '"') 23 + local p="$(attr_path "$1")" 24 + (cd "$root" && nix-instantiate --eval --strict -A $p.version | tr -d '"') 16 25 } 17 26 18 27 src_url() { 19 - nix-instantiate --eval --strict --expr " with import $root {}; let src = sourcehut.python.pkgs.$1.drvAttrs.src; in src.meta.homepage" | tr -d '"' 28 + local p="$(attr_path "$1")" 29 + nix-instantiate --eval --strict --expr " with import $root {}; let src = $p.drvAttrs.src; in src.meta.homepage" | tr -d '"' 20 30 } 21 31 22 32 get_latest_version() { ··· 35 45 default_nix="$(default "$1")" 36 46 oldVersion="$(version "$1")" 37 47 version="$(get_latest_version "$1")" 48 + local p="$(attr_path "$1")" 38 49 39 - (cd "$root" && update-source-version "sourcehut.python.pkgs.$1" "$version") 50 + (cd "$root" && update-source-version "$p" "$version") 40 51 41 52 # Update vendorHash of Go modules 42 53 retry=true