mirror of
https://github.com/sxyazi/yazi.git
synced 2024-10-27 03:27:42 +03:00
Merge a930638109
into 4aaca4c432
This commit is contained in:
commit
888bdee1bb
46
flake.lock
46
flake.lock
@ -1,30 +1,12 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1722141560,
|
||||
"narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=",
|
||||
"lastModified": 1722415718,
|
||||
"narHash": "sha256-5US0/pgxbMksF92k1+eOa8arJTJiPvsdZj9Dl+vJkM4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160",
|
||||
"rev": "c3392ad349a5227f4a3464dce87bcc5046692fce",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -36,7 +18,6 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
@ -48,11 +29,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722133294,
|
||||
"narHash": "sha256-XKSVN+lmjVEFPjMa5Ui0VTay2Uvqa74h0MQT0HU1pqw=",
|
||||
"lastModified": 1722391647,
|
||||
"narHash": "sha256-JTi7l1oxnatF1uX/gnGMlRnyFMtylRw4MqhCUdoN2K4=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "9803f6e04ca37a2c072783e8297d2080f8d0e739",
|
||||
"rev": "0fd4a5d2098faa516a9b83022aec7db766cd1de8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -60,21 +41,6 @@
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
102
flake.nix
102
flake.nix
@ -1,13 +1,9 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs = {
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
flake-utils.follows = "flake-utils";
|
||||
};
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
@ -15,47 +11,77 @@
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
rust-overlay,
|
||||
...
|
||||
}@inputs:
|
||||
}:
|
||||
let
|
||||
# Nixpkgs overlays
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
(final: _: {
|
||||
rustToolchain = final.rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; };
|
||||
})
|
||||
systems = [
|
||||
"aarch64-darwin"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
];
|
||||
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
forEachSystem =
|
||||
f:
|
||||
(lib.listToAttrs (
|
||||
map (system: {
|
||||
name = system;
|
||||
value = f {
|
||||
inherit system;
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
|
||||
(
|
||||
final: prev:
|
||||
let
|
||||
toolchain = final.rust-bin.stable.latest.default;
|
||||
in
|
||||
{
|
||||
rustPlatform = prev.makeRustPlatform {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
};
|
||||
}) systems
|
||||
));
|
||||
|
||||
rev = self.shortRev or self.dirtyShortRev or "dirty";
|
||||
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||
version =
|
||||
(builtins.fromTOML (builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
||||
+ "pre${builtins.substring 0 8 date}_${rev}";
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
rev = self.shortRev or "dirty";
|
||||
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||
version =
|
||||
(builtins.fromTOML (builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
||||
+ "pre${builtins.substring 0 8 date}_${rev}";
|
||||
{
|
||||
packages = forEachSystem (
|
||||
{ pkgs, system }:
|
||||
{
|
||||
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
|
||||
yazi = pkgs.callPackage ./nix/yazi.nix { inherit (self.packages.${system}) yazi-unwrapped; };
|
||||
default = self.packages.${system}.yazi;
|
||||
}
|
||||
);
|
||||
|
||||
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
|
||||
yazi = pkgs.callPackage ./nix/yazi.nix { inherit yazi-unwrapped; };
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
inherit yazi-unwrapped yazi;
|
||||
default = yazi;
|
||||
};
|
||||
devShells = forEachSystem (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
default = pkgs.callPackage ./nix/shell.nix { };
|
||||
}
|
||||
);
|
||||
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
formatter = forEachSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
|
||||
|
||||
devShells.default = import ./nix/shell.nix { inherit pkgs inputs; };
|
||||
}
|
||||
)
|
||||
// {
|
||||
overlays = rec {
|
||||
default = yazi;
|
||||
yazi = final: _: { inherit (self.packages."${final.system}") yazi yazi-unwrapped; };
|
||||
overlays = {
|
||||
default = self.overlays.yazi;
|
||||
yazi = _: prev: { inherit (self.packages.${prev.stdenv.system}) yazi yazi-unwrapped; };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -1,28 +1,24 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
rustToolchain
|
||||
rust-analyzer
|
||||
{
|
||||
callPackage,
|
||||
rust-bin,
|
||||
nodePackages,
|
||||
}:
|
||||
let
|
||||
mainPkg = callPackage ./yazi.nix { };
|
||||
in
|
||||
mainPkg.overrideAttrs (oa: {
|
||||
nativeBuildInputs = [
|
||||
(rust-bin.stable.latest.default.override {
|
||||
extensions = [
|
||||
"rust-src"
|
||||
"rustfmt"
|
||||
"rust-analyzer"
|
||||
"clippy"
|
||||
];
|
||||
})
|
||||
|
||||
nodePackages.cspell
|
||||
] ++ (oa.nativeBuildInputs or [ ]);
|
||||
|
||||
file
|
||||
jq
|
||||
poppler_utils
|
||||
unar
|
||||
ffmpegthumbnailer
|
||||
fd
|
||||
ripgrep
|
||||
fzf
|
||||
zoxide
|
||||
];
|
||||
|
||||
buildInputs =
|
||||
with pkgs;
|
||||
lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||
|
||||
env = {
|
||||
RUST_BACKTRACE = "1";
|
||||
};
|
||||
}
|
||||
env.RUST_BACKTRACE = "1";
|
||||
})
|
||||
|
@ -1,67 +1,76 @@
|
||||
{
|
||||
makeRustPlatform,
|
||||
rustToolchain,
|
||||
rustPlatform,
|
||||
version ? "git",
|
||||
rev,
|
||||
date,
|
||||
rev ? "unknown",
|
||||
date ? "19700101",
|
||||
lib,
|
||||
|
||||
installShellFiles,
|
||||
stdenv,
|
||||
darwin,
|
||||
rust-jemalloc-sys,
|
||||
|
||||
imagemagick,
|
||||
}:
|
||||
let
|
||||
src = lib.fileset.toSource {
|
||||
root = ../.;
|
||||
fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ../.)) (
|
||||
lib.fileset.unions [
|
||||
../assets
|
||||
../Cargo.toml
|
||||
../Cargo.lock
|
||||
(lib.fileset.fileFilter (file: file.hasExt "rs" || file.hasExt "toml") ../.)
|
||||
]
|
||||
);
|
||||
};
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "yazi";
|
||||
inherit version src;
|
||||
|
||||
(makeRustPlatform {
|
||||
cargo = rustToolchain;
|
||||
rustc = rustToolchain;
|
||||
}).buildRustPackage
|
||||
{
|
||||
pname = "yazi";
|
||||
inherit version;
|
||||
|
||||
src = ../.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
outputHashes = {
|
||||
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
||||
};
|
||||
cargoLock = {
|
||||
lockFile = "${src}/Cargo.lock";
|
||||
outputHashes = {
|
||||
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
||||
};
|
||||
};
|
||||
|
||||
env = {
|
||||
YAZI_GEN_COMPLETIONS = true;
|
||||
VERGEN_GIT_SHA = rev;
|
||||
VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
|
||||
};
|
||||
env = {
|
||||
YAZI_GEN_COMPLETIONS = true;
|
||||
VERGEN_GIT_SHA = rev;
|
||||
VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
imagemagick
|
||||
];
|
||||
buildInputs = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
imagemagick
|
||||
];
|
||||
|
||||
postInstall = ''
|
||||
installShellCompletion --cmd yazi \
|
||||
--bash ./yazi-boot/completions/yazi.bash \
|
||||
--fish ./yazi-boot/completions/yazi.fish \
|
||||
--zsh ./yazi-boot/completions/_yazi
|
||||
buildInputs = [
|
||||
rust-jemalloc-sys
|
||||
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||
|
||||
# Resize logo
|
||||
for RES in 16 24 32 48 64 128 256; do
|
||||
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
|
||||
magick assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
||||
done
|
||||
postInstall = ''
|
||||
installShellCompletion --cmd yazi \
|
||||
--bash ./yazi-boot/completions/yazi.bash \
|
||||
--fish ./yazi-boot/completions/yazi.fish \
|
||||
--zsh ./yazi-boot/completions/_yazi
|
||||
|
||||
mkdir -p $out/share/applications
|
||||
install -m644 assets/yazi.desktop $out/share/applications/
|
||||
'';
|
||||
# Resize logo
|
||||
for RES in 16 24 32 48 64 128 256; do
|
||||
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
|
||||
magick assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
||||
done
|
||||
|
||||
meta = {
|
||||
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
|
||||
homepage = "https://github.com/sxyazi/yazi";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "yazi";
|
||||
};
|
||||
}
|
||||
mkdir -p $out/share/applications
|
||||
install -m644 assets/yazi.desktop $out/share/applications/
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
|
||||
homepage = "https://github.com/sxyazi/yazi";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "yazi";
|
||||
};
|
||||
}
|
||||
|
95
nix/yazi.nix
95
nix/yazi.nix
@ -1,41 +1,89 @@
|
||||
{
|
||||
lib,
|
||||
formats,
|
||||
runCommand,
|
||||
makeWrapper,
|
||||
|
||||
extraPackages ? [ ],
|
||||
optionalDeps ? [
|
||||
jq
|
||||
poppler_utils
|
||||
unar
|
||||
ffmpegthumbnailer
|
||||
fd
|
||||
ripgrep
|
||||
fzf
|
||||
zoxide
|
||||
],
|
||||
|
||||
# deps
|
||||
file,
|
||||
yazi-unwrapped,
|
||||
|
||||
withFile ? true,
|
||||
file,
|
||||
withJq ? true,
|
||||
# optional deps
|
||||
jq,
|
||||
withPoppler ? true,
|
||||
poppler_utils,
|
||||
withUnar ? true,
|
||||
unar,
|
||||
withFfmpegthumbnailer ? true,
|
||||
ffmpegthumbnailer,
|
||||
withFd ? true,
|
||||
fd,
|
||||
withRipgrep ? true,
|
||||
ripgrep,
|
||||
withFzf ? true,
|
||||
fzf,
|
||||
withZoxide ? true,
|
||||
zoxide,
|
||||
}:
|
||||
|
||||
settings ? { },
|
||||
plugins ? { },
|
||||
flavors ? { },
|
||||
initLua ? null,
|
||||
}:
|
||||
let
|
||||
inherit (lib) optional makeBinPath;
|
||||
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;
|
||||
inherit (lib)
|
||||
concatStringsSep
|
||||
concatMapStringsSep
|
||||
optionalString
|
||||
makeBinPath
|
||||
mapAttrsToList
|
||||
;
|
||||
|
||||
runtimePaths = [ file ] ++ optionalDeps ++ extraPackages;
|
||||
|
||||
settingsFormat = formats.toml { };
|
||||
|
||||
files = [
|
||||
"yazi"
|
||||
"theme"
|
||||
"keymap"
|
||||
];
|
||||
|
||||
configHome =
|
||||
if (settings == { } && initLua == null && plugins == { } && flavors == { }) then
|
||||
null
|
||||
else
|
||||
runCommand "YAZI_CONFIG_HOME" { } ''
|
||||
mkdir -p $out
|
||||
${concatMapStringsSep "\n" (
|
||||
name:
|
||||
optionalString (settings ? ${name} && settings.${name} != { }) ''
|
||||
ln -s ${settingsFormat.generate "${name}.toml" settings.${name}} $out/${name}.toml
|
||||
''
|
||||
) files}
|
||||
|
||||
mkdir $out/plugins
|
||||
${optionalString (plugins != { }) ''
|
||||
${concatStringsSep "\n" (
|
||||
mapAttrsToList (name: value: "ln -s ${value} $out/plugins/${name}") plugins
|
||||
)}
|
||||
''}
|
||||
|
||||
mkdir $out/flavors
|
||||
${optionalString (flavors != { }) ''
|
||||
${concatStringsSep "\n" (
|
||||
mapAttrsToList (name: value: "ln -s ${value} $out/flavors/${name}") flavors
|
||||
)}
|
||||
''}
|
||||
|
||||
|
||||
${optionalString (initLua != null) "ln -s ${initLua} $out/init.lua"}
|
||||
'';
|
||||
in
|
||||
runCommand yazi-unwrapped.name
|
||||
{
|
||||
@ -48,5 +96,6 @@ runCommand yazi-unwrapped.name
|
||||
ln -s ${yazi-unwrapped}/share $out/share
|
||||
ln -s ${yazi-unwrapped}/bin/ya $out/bin/ya
|
||||
makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \
|
||||
--prefix PATH : "${makeBinPath runtimePaths}"
|
||||
--prefix PATH : "${makeBinPath runtimePaths}" \
|
||||
${optionalString (configHome != null) "--set YAZI_CONFIG_HOME ${configHome}"}
|
||||
''
|
||||
|
Loading…
Reference in New Issue
Block a user