Skip to content

Commit 228ff38

Browse files
authored
yazi-unwrapped: fix update script; use finalAttrs (#385409)
2 parents 4d4555c + a773507 commit 228ff38

File tree

2 files changed

+41
-34
lines changed

2 files changed

+41
-34
lines changed

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

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,13 @@
88
Foundation,
99
rust-jemalloc-sys,
1010
}:
11-
let
11+
rustPlatform.buildRustPackage (finalAttrs: {
12+
pname = "yazi";
1213
version = "25.2.26";
1314

14-
code_src = fetchFromGitHub {
15-
owner = "sxyazi";
16-
repo = "yazi";
17-
tag = "v${version}";
18-
hash = "sha256-DqhqpQRCSBTGonL9+bP7pA3mO2CemlbhwzShVdrL1/0=";
19-
};
15+
srcs = builtins.attrValues finalAttrs.passthru.srcs;
2016

21-
man_src = fetchFromGitHub {
22-
name = "manpages"; # needed to ensure name is unique
23-
owner = "yazi-rs";
24-
repo = "manpages";
25-
rev = "8950e968f4a1ad0b83d5836ec54a070855068dbf";
26-
hash = "sha256-kEVXejDg4ChFoMNBvKlwdFEyUuTcY2VuK9j0PdafKus=";
27-
};
28-
in
29-
rustPlatform.buildRustPackage rec {
30-
pname = "yazi";
31-
inherit version;
32-
33-
srcs = [
34-
code_src
35-
man_src
36-
];
37-
sourceRoot = code_src.name;
17+
sourceRoot = finalAttrs.passthru.srcs.code_src.name;
3818

3919
useFetchCargoVendor = true;
4020
cargoHash = "sha256-xg37aypFKY0ZG9GOkygTHlOAjqkTuhLNKo8Fz6MF2ZY=";
@@ -52,13 +32,29 @@ rustPlatform.buildRustPackage rec {
5232
--fish ./yazi-boot/completions/yazi.fish \
5333
--zsh ./yazi-boot/completions/_yazi
5434
55-
installManPage ../${man_src.name}/yazi{.1,-config.5}
35+
installManPage ../${finalAttrs.passthru.srcs.man_src.name}/yazi{.1,-config.5}
5636
5737
install -Dm444 assets/yazi.desktop -t $out/share/applications
5838
install -Dm444 assets/logo.png $out/share/pixmaps/yazi.png
5939
'';
6040

6141
passthru.updateScript.command = [ ./update.sh ];
42+
passthru.srcs = {
43+
code_src = fetchFromGitHub {
44+
owner = "sxyazi";
45+
repo = "yazi";
46+
tag = "v${finalAttrs.version}";
47+
hash = "sha256-DqhqpQRCSBTGonL9+bP7pA3mO2CemlbhwzShVdrL1/0=";
48+
};
49+
50+
man_src = fetchFromGitHub {
51+
name = "manpages"; # needed to ensure name is unique
52+
owner = "yazi-rs";
53+
repo = "manpages";
54+
rev = "8950e968f4a1ad0b83d5836ec54a070855068dbf";
55+
hash = "sha256-kEVXejDg4ChFoMNBvKlwdFEyUuTcY2VuK9j0PdafKus=";
56+
};
57+
};
6258

6359
meta = {
6460
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
@@ -74,4 +70,4 @@ rustPlatform.buildRustPackage rec {
7470
];
7571
mainProgram = "yazi";
7672
};
77-
}
73+
})

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)