1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p coreutils curl jq common-updater-scripts dotnet-sdk_6 git gnupg nixFlakes
5 # This script uses the following env vars:
9 trap 'echo "Error at ${BASH_SOURCE[0]}:$LINENO"' ERR
13 : ${getVersionFromTags:=}
16 scriptDir
=$
(cd "${BASH_SOURCE[0]%/*}" && pwd)
17 nixpkgs
=$
(realpath
"$scriptDir"/..
/..
/..
/..
/..
)
20 nix
eval --impure --raw --expr "(with import \"$nixpkgs\" {}; $1)"
24 url
=$
(evalNixpkgs
$pkgName.src.meta.homepage
)
25 echo $
(basename $
(dirname $url))/$
(basename $url)
28 getLatestVersionTag
() {
29 "$nixpkgs"/pkgs
/common-updater
/scripts
/list-git-tags
--url=https
://github.com
/$
(getRepo
) 2>/dev
/null \
30 |
sort -V |
tail -1 |
sed 's|^v||'
33 oldVersion
=$
(evalNixpkgs
"$pkgName.version")
34 if [[ $getVersionFromTags ]]; then
35 newVersion
=$
(getLatestVersionTag
)
37 newVersion
=$
(curl
-s "https://api.github.com/repos/$(getRepo)/releases" | jq
-r '.[0].name')
40 if [[ $newVersion == $oldVersion && ! $refetch ]]; then
41 echo "nixpkgs already has the latest version $newVersion"
42 echo "Run this script with env var refetch=1 to re-verify the content hash via GPG"
43 echo "and to recreate deps.nix. This is useful for reviewing a version update."
47 # Fetch release and GPG-verify the content hash
48 tmpdir
=$
(mktemp
-d /tmp
/$pkgName-verify-gpg.XXX
)
50 trap "rm -rf $tmpdir" EXIT
51 git clone
--depth 1 --branch v
${newVersion} -c advice.detachedHead
=false https
://github.com
/$
(getRepo
) $repo
52 export GNUPGHOME
=$tmpdir
53 # Fetch Nicolas Dorier's key (64-bit key ID: 6618763EF09186FE)
54 gpg
--keyserver hkps
://keyserver.ubuntu.com
--recv-keys AB4CFA9895ACA0DBE27F6B346618763EF09186FE
2> /dev
/null
55 # Fetch Andrew Camilleri's key (64-bit key ID: 8E5530D9D1C93097)
56 gpg
--keyserver hkps
://keyserver.ubuntu.com
--recv-keys 836C08CF3F523BB7A8CB8ECF8E5530D9D1C93097
2> /dev
/null
58 echo "Verifying commit"
59 git
-C $repo verify-commit HEAD
61 newHash
=$
(nix hash-path
$repo)
65 # Update pkg version and hash
66 echo "Updating $pkgName: $oldVersion -> $newVersion"
67 if [[ $newVersion == $oldVersion ]]; then
68 # Temporarily set a source version that doesn't equal $newVersion so that $newHash
69 # is always updated in the next call to update-source-version.
70 (cd "$nixpkgs" && update-source-version
"$pkgName" "0" "0000000000000000000000000000000000000000000000000000")
72 (cd "$nixpkgs" && update-source-version
"$pkgName" "$newVersion" "$newHash")
76 $
(nix-build
"$nixpkgs" -A $pkgName.fetch-deps
--no-out-link)