mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: support yazi-cli for Nix flake (#944)
This commit is contained in:
parent
c65a14c0e6
commit
8fc8770c28
5 changed files with 94 additions and 72 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [ "yazi-*" ]
|
members = [ "yazi-*" ]
|
||||||
default-members = [ "yazi-fm" ]
|
default-members = [ "yazi-fm", "yazi-cli" ]
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
|
||||||
18
flake.lock
generated
18
flake.lock
generated
|
|
@ -5,11 +5,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1694529238,
|
"lastModified": 1710146030,
|
||||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -20,11 +20,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701174899,
|
"lastModified": 1713805509,
|
||||||
"narHash": "sha256-1W+FMe8mWsJKXoBc+QgKmEeRj33kTFnPq7XCjU+bfnA=",
|
"narHash": "sha256-YgSEan4CcrjivCNO5ZNzhg7/8ViLkZ4CB/GrGBVSudo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "010c7296f3b19a58b206fdf7d68d75a5b0a09e9e",
|
"rev": "1e1dc66fe68972a76679644a5577828b6a7e8be4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -51,11 +51,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701224160,
|
"lastModified": 1713924823,
|
||||||
"narHash": "sha256-qnMmxNMKmd6Soel0cfauyMJ+LzuZbvmiDQPSIuTbQ+M=",
|
"narHash": "sha256-kOeyS3GFwgnKvzuBMmFqEAX0xwZ7Nj4/5tXuvpZ0d4U=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "4a080e26d55eaedb95ab1bf8eeaeb84149c10f12",
|
"rev": "8a2edac3ae926a2a6ce60f4595dcc4540fc8cad4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
11
flake.nix
11
flake.nix
|
|
@ -34,11 +34,15 @@
|
||||||
version = (builtins.fromTOML
|
version = (builtins.fromTOML
|
||||||
(builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
(builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
||||||
+ versionSuffix;
|
+ versionSuffix;
|
||||||
yazi = pkgs.callPackage ./nix/yazi.nix { inherit version; };
|
|
||||||
|
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version; };
|
||||||
|
yazi = pkgs.callPackage ./nix/yazi.nix { inherit yazi-unwrapped; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.default = yazi;
|
packages = {
|
||||||
packages.yazi = yazi;
|
inherit yazi-unwrapped yazi;
|
||||||
|
default = yazi;
|
||||||
|
};
|
||||||
|
|
||||||
formatter = pkgs.nixpkgs-fmt;
|
formatter = pkgs.nixpkgs-fmt;
|
||||||
|
|
||||||
|
|
@ -48,6 +52,7 @@
|
||||||
overlays = rec {
|
overlays = rec {
|
||||||
default = yazi;
|
default = yazi;
|
||||||
yazi = final: prev: {
|
yazi = final: prev: {
|
||||||
|
yazi-unwrapped = self.packages."${final.system}".yazi-unwrapped;
|
||||||
yazi = self.packages."${final.system}".yazi;
|
yazi = self.packages."${final.system}".yazi;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
50
nix/yazi-unwrapped.nix
Normal file
50
nix/yazi-unwrapped.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
{ makeRustPlatform
|
||||||
|
, rustToolchain
|
||||||
|
, version ? "git"
|
||||||
|
, lib
|
||||||
|
|
||||||
|
, installShellFiles
|
||||||
|
, stdenv
|
||||||
|
, darwin
|
||||||
|
|
||||||
|
, imagemagick
|
||||||
|
}:
|
||||||
|
|
||||||
|
(makeRustPlatform { cargo = rustToolchain; rustc = rustToolchain; }).buildRustPackage rec {
|
||||||
|
pname = "yazi";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = ../.;
|
||||||
|
|
||||||
|
cargoLock.lockFile = ../Cargo.lock;
|
||||||
|
|
||||||
|
env.YAZI_GEN_COMPLETIONS = true;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ installShellFiles imagemagick ];
|
||||||
|
buildInputs = lib.optionals stdenv.isDarwin (
|
||||||
|
with darwin.apple_sdk.frameworks; [ Foundation ]
|
||||||
|
);
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
installShellCompletion --cmd yazi \
|
||||||
|
--bash ./yazi-boot/completions/yazi.bash \
|
||||||
|
--fish ./yazi-boot/completions/yazi.fish \
|
||||||
|
--zsh ./yazi-boot/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/
|
||||||
|
'';
|
||||||
|
|
||||||
|
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;
|
||||||
|
mainProgram = "yazi";
|
||||||
|
};
|
||||||
|
}
|
||||||
85
nix/yazi.nix
85
nix/yazi.nix
|
|
@ -1,12 +1,7 @@
|
||||||
{ makeRustPlatform
|
{ lib
|
||||||
, rustToolchain
|
, runCommand
|
||||||
, version ? "git"
|
|
||||||
, lib
|
|
||||||
|
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
, installShellFiles
|
, yazi-unwrapped
|
||||||
, stdenv
|
|
||||||
, darwin
|
|
||||||
|
|
||||||
, withFile ? true
|
, withFile ? true
|
||||||
, file
|
, file
|
||||||
|
|
@ -26,57 +21,29 @@
|
||||||
, fzf
|
, fzf
|
||||||
, withZoxide ? true
|
, withZoxide ? true
|
||||||
, zoxide
|
, zoxide
|
||||||
, imagemagick
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
(makeRustPlatform { cargo = rustToolchain; rustc = rustToolchain; }).buildRustPackage {
|
let
|
||||||
pname = "yazi";
|
runtimePaths = with lib; [ ]
|
||||||
inherit version;
|
++ 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;
|
||||||
|
|
||||||
src = ../.;
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
YAZI_GEN_COMPLETIONS = true;
|
} ''
|
||||||
|
mkdir -p $out/bin
|
||||||
cargoLock.lockFile = ../Cargo.lock;
|
ln -s ${yazi-unwrapped}/share $out/share
|
||||||
|
ln -s ${yazi-unwrapped}/bin/ya $out/bin/ya
|
||||||
nativeBuildInputs = [ makeWrapper installShellFiles imagemagick ];
|
makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \
|
||||||
buildInputs = lib.optionals stdenv.isDarwin (
|
--prefix PATH : "${lib.makeBinPath runtimePaths}"
|
||||||
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 \
|
|
||||||
--bash ./yazi-boot/completions/yazi.bash \
|
|
||||||
--fish ./yazi-boot/completions/yazi.fish \
|
|
||||||
--zsh ./yazi-boot/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/
|
|
||||||
'';
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue