yazi-unwrapped: auto update version, build date & hash
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
stdenv,
|
||||
Foundation,
|
||||
rust-jemalloc-sys,
|
||||
|
||||
nix-update-script,
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
@@ -49,7 +47,7 @@ rustPlatform.buildRustPackage rec {
|
||||
install -Dm444 assets/logo.png $out/share/pixmaps/yazi.png
|
||||
'';
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
passthru.updateScript.command = [ ./update.sh ];
|
||||
|
||||
meta = {
|
||||
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
|
||||
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p bash nix-update curl coreutils jq common-updater-scripts nix-prefetch
|
||||
|
||||
set -eux
|
||||
|
||||
NIXPKGS_DIR="$PWD"
|
||||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
# Get latest release
|
||||
YAZI_RELEASE=$(
|
||||
curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
|
||||
https://api.github.com/repos/sxyazi/yazi/releases/latest
|
||||
)
|
||||
|
||||
# Get release information
|
||||
latestBuildDate=$(echo "$YAZI_RELEASE" | jq -r ".published_at")
|
||||
latestVersion=$(echo "$YAZI_RELEASE" | jq -r ".tag_name")
|
||||
|
||||
latestBuildDate="${latestBuildDate%T*}" # remove the timestamp and get the date
|
||||
latestVersion="${latestVersion:1}" # remove first char 'v'
|
||||
|
||||
oldVersion=$(nix eval --raw -f "$NIXPKGS_DIR" yazi-unwrapped.version)
|
||||
|
||||
if [[ "$oldVersion" == "$latestVersion" ]]; then
|
||||
echo "Yazi is up-to-date: ${oldVersion}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Updating Yazi"
|
||||
|
||||
# Version
|
||||
update-source-version yazi-unwrapped "${latestVersion}"
|
||||
|
||||
pushd "$SCRIPT_DIR"
|
||||
# Build date
|
||||
sed -i 's#env.VERGEN_BUILD_DATE = "[^"]*"#env.VERGEN_BUILD_DATE = "'"${latestBuildDate}"'"#' package.nix
|
||||
|
||||
# Hashes
|
||||
cargoHash=$(nix-prefetch "{ sha256 }: (import $NIXPKGS_DIR {}).yazi-unwrapped.cargoDeps.overrideAttrs (_: { outputHash = sha256; })")
|
||||
sed -i -E 's#\bcargoHash = ".*?"#cargoHash = "'"$cargoHash"'"#' package.nix
|
||||
popd
|
||||
Reference in New Issue
Block a user