From a446fd03009bff2c14dc61ed3137cc9ae09659e0 Mon Sep 17 00:00:00 2001 From: linsui Date: Sun, 18 Feb 2024 23:24:18 +0800 Subject: [PATCH] yazi: use wrapper to avoid rebuild --- .../file-managers/yazi/default.nix | 81 ------------------- pkgs/by-name/ya/yazi-unwrapped/package.nix | 46 +++++++++++ pkgs/by-name/ya/yazi/package.nix | 48 +++++++++++ pkgs/top-level/all-packages.nix | 2 +- 4 files changed, 95 insertions(+), 82 deletions(-) delete mode 100644 pkgs/applications/file-managers/yazi/default.nix create mode 100644 pkgs/by-name/ya/yazi-unwrapped/package.nix create mode 100644 pkgs/by-name/ya/yazi/package.nix diff --git a/pkgs/applications/file-managers/yazi/default.nix b/pkgs/applications/file-managers/yazi/default.nix deleted file mode 100644 index c59827f3191f..000000000000 --- a/pkgs/applications/file-managers/yazi/default.nix +++ /dev/null @@ -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"; - }; -} diff --git a/pkgs/by-name/ya/yazi-unwrapped/package.nix b/pkgs/by-name/ya/yazi-unwrapped/package.nix new file mode 100644 index 000000000000..4c2d1065fad6 --- /dev/null +++ b/pkgs/by-name/ya/yazi-unwrapped/package.nix @@ -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"; + }; +} diff --git a/pkgs/by-name/ya/yazi/package.nix b/pkgs/by-name/ya/yazi/package.nix new file mode 100644 index 000000000000..134db023edd9 --- /dev/null +++ b/pkgs/by-name/ya/yazi/package.nix @@ -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}" +'' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ec9b96b86674..7b71869ade06 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -41889,7 +41889,7 @@ with pkgs; 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 { };