yazi/nix/yazi.nix

83 lines
2.0 KiB
Nix
Raw Normal View History

2023-11-29 16:45:47 +03:00
{ makeRustPlatform
, rustToolchain
2023-09-22 11:08:17 +03:00
, version ? "git"
, lib
, makeWrapper
, installShellFiles
2023-09-22 11:08:17 +03:00
, stdenv
, darwin
, 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
, imagemagick
2023-09-22 11:08:17 +03:00
}:
2023-11-29 16:45:47 +03:00
(makeRustPlatform { cargo = rustToolchain; rustc = rustToolchain; }).buildRustPackage {
2023-09-22 11:08:17 +03:00
pname = "yazi";
inherit version;
src = ../.;
2023-10-23 12:25:16 +03:00
YAZI_GEN_COMPLETIONS = true;
2023-09-22 11:08:17 +03:00
cargoLock.lockFile = ../Cargo.lock;
nativeBuildInputs = [ makeWrapper installShellFiles imagemagick ];
2023-09-22 11:08:17 +03:00
buildInputs = lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks; [ 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 \
2023-10-23 12:25:16 +03:00
--bash ./yazi-config/completions/yazi.bash \
--fish ./yazi-config/completions/yazi.fish \
--zsh ./yazi-config/completions/_yazi
# Resize logo
for RES in 16 24 32 48 64 128 256; do
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
convert assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
done
mkdir -p $out/share/applications
install -m644 assets/yazi.desktop $out/share/applications/
2023-09-22 11:08:17 +03:00
'';
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;
};
}