Skip to content

Commit fe544f3

Browse files
committed
yazi-unwrapped: fix update script
1 parent 47ac175 commit fe544f3

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

pkgs/by-name/ya/yazi-unwrapped/package.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ let
2626
hash = "sha256-kEVXejDg4ChFoMNBvKlwdFEyUuTcY2VuK9j0PdafKus=";
2727
};
2828
in
29-
rustPlatform.buildRustPackage rec {
29+
rustPlatform.buildRustPackage {
3030
pname = "yazi";
3131
inherit version;
3232

3333
srcs = [
3434
code_src
3535
man_src
3636
];
37+
3738
sourceRoot = code_src.name;
3839

3940
useFetchCargoVendor = true;
@@ -59,6 +60,7 @@ rustPlatform.buildRustPackage rec {
5960
'';
6061

6162
passthru.updateScript.command = [ ./update.sh ];
63+
passthru.srcs = { inherit code_src man_src; }; # for updating sources
6264

6365
meta = {
6466
description = "Blazing fast terminal file manager written in Rust, based on async I/O";

pkgs/by-name/ya/yazi-unwrapped/update.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env nix-shell
2-
#!nix-shell -i bash -p bash nix-update curl coreutils jq common-updater-scripts nix-prefetch
2+
#!nix-shell -i bash -p bash nix-update curl coreutils jq common-updater-scripts gawk
33

44
set -eux
55

@@ -26,16 +26,27 @@ if [[ "$oldVersion" == "$latestVersion" ]]; then
2626
exit 0
2727
fi
2828

29-
echo "Updating Yazi"
29+
echo "Updating code sources"
3030

31-
# Version
32-
update-source-version yazi-unwrapped "${latestVersion}"
31+
update-source-version yazi-unwrapped "${latestVersion}" --source-key=passthru.srcs.code_src
3332

3433
pushd "$SCRIPT_DIR"
35-
# Build date
34+
echo "Updating build date"
35+
3636
sed -i 's#env.VERGEN_BUILD_DATE = "[^"]*"#env.VERGEN_BUILD_DATE = "'"${latestBuildDate}"'"#' package.nix
3737

38-
# Hashes
39-
cargoHash=$(nix-prefetch "{ sha256 }: (import $NIXPKGS_DIR {}).yazi-unwrapped.cargoDeps.overrideAttrs (_: { outputHash = sha256; })")
40-
sed -i -E 's#\bcargoHash = ".*?"#cargoHash = "'"$cargoHash"'"#' package.nix
38+
echo "Updating cargoHash"
39+
40+
# Set cargoHash to an empty string
41+
sed -i -E 's/cargoHash = ".*?"/cargoHash = ""/' package.nix
42+
43+
# Build and get new hash
44+
cargoHash=$( (nix-build "$NIXPKGS_DIR" -A yazi-unwrapped 2>&1 || true) | awk '/got/{print $2}')
45+
46+
if [ "$cargoHash" == "" ]; then
47+
echo "Failed to get cargoHash, please update it manually"
48+
exit 0
49+
fi
50+
51+
sed -i -E 's/cargoHash = ".*?"/cargoHash = "'"$cargoHash"'"/' package.nix
4152
popd

0 commit comments

Comments
 (0)