yazi: use wrapper to avoid rebuild

This commit is contained in:
linsui 2024-02-18 23:24:18 +08:00
parent 6ecec40792
commit a446fd0300
4 changed files with 95 additions and 82 deletions

View File

@ -1,81 +0,0 @@
{ rustPlatform
, fetchFromGitHub
, lib
, makeWrapper
, installShellFiles
, stdenv
, Foundation
, withFile ? true
, file
, withJq ? true
, jq
, withPoppler ? true
, poppler_utils
, withUnar ? true
, unar
, withFfmpegthumbnailer ? true
, ffmpegthumbnailer
, withFd ? true
, fd
, withRipgrep ? true
, ripgrep
, withFzf ? true
, fzf
, withZoxide ? true
, zoxide
, nix-update-script
}:
rustPlatform.buildRustPackage rec {
pname = "yazi";
version = "0.2.3";
src = fetchFromGitHub {
owner = "sxyazi";
repo = pname;
rev = "v${version}";
hash = "sha256-2AiaJs6xY8hsB1DBxpPwdZtc8IZvsoCGWBOFVMf4dvk=";
};
cargoHash = "sha256-fRUmXv27sHYz8z0cc795JCPLHDQGgTV4wAWAtQ/pbg4=";
env.YAZI_GEN_COMPLETIONS = true;
nativeBuildInputs = [ makeWrapper installShellFiles ];
buildInputs = lib.optionals stdenv.isDarwin [ Foundation ];
postInstall = with lib;
let
runtimePaths = [ ]
++ optional withFile file
++ optional withJq jq
++ optional withPoppler poppler_utils
++ optional withUnar unar
++ optional withFfmpegthumbnailer ffmpegthumbnailer
++ optional withFd fd
++ optional withRipgrep ripgrep
++ optional withFzf fzf
++ optional withZoxide zoxide;
in
''
wrapProgram $out/bin/yazi \
--prefix PATH : "${makeBinPath runtimePaths}"
installShellCompletion --cmd yazi \
--bash ./yazi-config/completions/yazi.bash \
--fish ./yazi-config/completions/yazi.fish \
--zsh ./yazi-config/completions/_yazi
'';
passthru.updateScript = nix-update-script { };
meta = with lib; {
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
homepage = "https://github.com/sxyazi/yazi";
license = licenses.mit;
maintainers = with maintainers; [ xyenon matthiasbeyer ];
mainProgram = "yazi";
};
}

View File

@ -0,0 +1,46 @@
{ rustPlatform
, fetchFromGitHub
, lib
, installShellFiles
, stdenv
, Foundation
, nix-update-script
}:
rustPlatform.buildRustPackage rec {
pname = "yazi";
version = "0.2.3";
src = fetchFromGitHub {
owner = "sxyazi";
repo = pname;
rev = "v${version}";
hash = "sha256-2AiaJs6xY8hsB1DBxpPwdZtc8IZvsoCGWBOFVMf4dvk=";
};
cargoHash = "sha256-fRUmXv27sHYz8z0cc795JCPLHDQGgTV4wAWAtQ/pbg4=";
env.YAZI_GEN_COMPLETIONS = true;
nativeBuildInputs = [ installShellFiles ];
buildInputs = lib.optionals stdenv.isDarwin [ Foundation ];
postInstall = ''
installShellCompletion --cmd yazi \
--bash ./yazi-config/completions/yazi.bash \
--fish ./yazi-config/completions/yazi.fish \
--zsh ./yazi-config/completions/_yazi
'';
passthru.updateScript = nix-update-script { };
meta = with lib; {
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
homepage = "https://github.com/sxyazi/yazi";
license = licenses.mit;
maintainers = with maintainers; [ xyenon matthiasbeyer ];
mainProgram = "yazi";
};
}

View File

@ -0,0 +1,48 @@
{ lib
, runCommand
, makeWrapper
, yazi-unwrapped
, withFile ? true
, file
, withJq ? true
, jq
, withPoppler ? true
, poppler_utils
, withUnar ? true
, unar
, withFfmpegthumbnailer ? true
, ffmpegthumbnailer
, withFd ? true
, fd
, withRipgrep ? true
, ripgrep
, withFzf ? true
, fzf
, withZoxide ? true
, zoxide
}:
let
runtimePaths = with lib; [ ]
++ optional withFile file
++ optional withJq jq
++ optional withPoppler poppler_utils
++ optional withUnar unar
++ optional withFfmpegthumbnailer ffmpegthumbnailer
++ optional withFd fd
++ optional withRipgrep ripgrep
++ optional withFzf fzf
++ optional withZoxide zoxide;
in
runCommand yazi-unwrapped.name
{
inherit (yazi-unwrapped) pname version meta;
nativeBuildInputs = [ makeWrapper ];
} ''
mkdir -p $out/bin
ln -s ${yazi-unwrapped}/share $out/share
makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \
--prefix PATH : "${lib.makeBinPath runtimePaths}"
''

View File

@ -41889,7 +41889,7 @@ with pkgs;
weggli = callPackage ../tools/security/weggli { }; weggli = callPackage ../tools/security/weggli { };
yazi = callPackage ../applications/file-managers/yazi { inherit (darwin.apple_sdk.frameworks) Foundation; }; yazi-unwrapped = callPackage ../by-name/ya/yazi-unwrapped/package.nix { inherit (darwin.apple_sdk.frameworks) Foundation; };
ssl-proxy = callPackage ../tools/networking/ssl-proxy { }; ssl-proxy = callPackage ../tools/networking/ssl-proxy { };