1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl gnused nix jq
5 PKG_DIR
=$
(dirname "${BASH_SOURCE[@]}")
6 FILE
="$PKG_DIR/default.nix"
7 NIXPKGS_ROOT
=$
(cd $PKG_DIR && git rev-parse
--show-toplevel)
10 PREV_VERSION
=$
(nix
eval --raw -f $NIXPKGS_ROOT/default.nix
$ATTR.version
)
11 LATEST_TAG
=$
(curl
${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} --silent https
://api.github.com
/repos
/stefanprodan
/timoni
/releases
/latest | jq
-r '.tag_name')
12 NEXT_VERSION
=$
(echo ${LATEST_TAG} |
sed 's/^v//')
15 sed -i "s|$PREV_VERSION|$NEXT_VERSION|" "$FILE"
18 PREV_HASH
=$
(nix
eval --raw -f $NIXPKGS_ROOT/default.nix
$ATTR.src.outputHash
)
19 NEXT_HASH
=$
(nix
hash to-sri
--type sha256 $
(nix-prefetch-url
--unpack --type sha256 $
(nix
eval --raw -f $NIXPKGS_ROOT/default.nix
$ATTR.src.url
)))
20 sed -i "s|$PREV_HASH|$NEXT_HASH|" "$FILE"
23 PREV_VENDOR_HASH
=$
(nix
eval --raw -f $NIXPKGS_ROOT/default.nix
$ATTR.vendorHash
)
24 EMPTY_HASH
="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
25 sed -i "s|$PREV_VENDOR_HASH|$EMPTY_HASH|" "$FILE"
28 NEXT_VENDOR_HASH
=$
(nix-build
$NIXPKGS_ROOT --no-out-link -A $ATTR 2>&1 |
grep "got:" | cut
-d':' -f2 |
sed 's| ||g')
31 if [ -z "${NEXT_VENDOR_HASH:-}" ]; then
32 echo "Update failed. NEXT_VENDOR_HASH is empty." >&2
36 sed -i "s|$EMPTY_HASH|$NEXT_VENDOR_HASH|" "$FILE"
41 "oldVersion": "$PREV_VERSION",
42 "newVersion": "$NEXT_VERSION",
43 "files": ["$PWD/default.nix.nix"]