mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
refactor(nix): home keeping
This commit is contained in:
parent
c7b002581a
commit
feec48b752
5 changed files with 230 additions and 175 deletions
46
flake.lock
generated
46
flake.lock
generated
|
|
@ -1,30 +1,12 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722141560,
|
"lastModified": 1722415718,
|
||||||
"narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=",
|
"narHash": "sha256-5US0/pgxbMksF92k1+eOa8arJTJiPvsdZj9Dl+vJkM4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160",
|
"rev": "c3392ad349a5227f4a3464dce87bcc5046692fce",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -36,7 +18,6 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
}
|
}
|
||||||
|
|
@ -48,11 +29,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722133294,
|
"lastModified": 1722391647,
|
||||||
"narHash": "sha256-XKSVN+lmjVEFPjMa5Ui0VTay2Uvqa74h0MQT0HU1pqw=",
|
"narHash": "sha256-JTi7l1oxnatF1uX/gnGMlRnyFMtylRw4MqhCUdoN2K4=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "9803f6e04ca37a2c072783e8297d2080f8d0e739",
|
"rev": "0fd4a5d2098faa516a9b83022aec7db766cd1de8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -60,21 +41,6 @@
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"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",
|
"root": "root",
|
||||||
|
|
|
||||||
102
flake.nix
102
flake.nix
|
|
@ -1,13 +1,9 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs = {
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
nixpkgs.follows = "nixpkgs";
|
|
||||||
flake-utils.follows = "flake-utils";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -15,47 +11,77 @@
|
||||||
{
|
{
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
flake-utils,
|
|
||||||
rust-overlay,
|
rust-overlay,
|
||||||
...
|
...
|
||||||
}@inputs:
|
}:
|
||||||
let
|
let
|
||||||
# Nixpkgs overlays
|
systems = [
|
||||||
overlays = [
|
"aarch64-darwin"
|
||||||
rust-overlay.overlays.default
|
"aarch64-linux"
|
||||||
(final: _: {
|
"x86_64-darwin"
|
||||||
rustToolchain = final.rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; };
|
"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.override { extensions = [ "rust-src" ]; };
|
||||||
|
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
|
in
|
||||||
flake-utils.lib.eachDefaultSystem (
|
{
|
||||||
system:
|
packages = forEachSystem (
|
||||||
let
|
{ pkgs, system }:
|
||||||
pkgs = import nixpkgs { inherit system overlays; };
|
{
|
||||||
rev = self.shortRev or "dirty";
|
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
|
||||||
date = self.lastModifiedDate or self.lastModified or "19700101";
|
yazi = pkgs.callPackage ./nix/yazi.nix { inherit (self.packages.${system}) yazi-unwrapped; };
|
||||||
version =
|
default = self.packages.${system}.yazi;
|
||||||
(builtins.fromTOML (builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
}
|
||||||
+ "pre${builtins.substring 0 8 date}_${rev}";
|
);
|
||||||
|
|
||||||
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
|
devShells = forEachSystem (
|
||||||
yazi = pkgs.callPackage ./nix/yazi.nix { inherit yazi-unwrapped; };
|
{ pkgs, ... }:
|
||||||
in
|
{
|
||||||
{
|
default = pkgs.callPackage ./nix/shell.nix { };
|
||||||
packages = {
|
}
|
||||||
inherit yazi-unwrapped yazi;
|
);
|
||||||
default = yazi;
|
|
||||||
};
|
|
||||||
|
|
||||||
formatter = pkgs.nixfmt-rfc-style;
|
formatter = forEachSystem ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
|
||||||
|
|
||||||
devShells.default = import ./nix/shell.nix { inherit pkgs inputs; };
|
overlays = {
|
||||||
}
|
default = self.overlays.yazi;
|
||||||
)
|
yazi = _: prev: { inherit (self.packages.${prev.stdenv.system}) yazi yazi-unwrapped; };
|
||||||
// {
|
|
||||||
overlays = rec {
|
|
||||||
default = yazi;
|
|
||||||
yazi = final: _: { inherit (self.packages."${final.system}") yazi yazi-unwrapped; };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,23 @@
|
||||||
{ pkgs, ... }:
|
{
|
||||||
|
callPackage,
|
||||||
pkgs.mkShell {
|
rust-bin,
|
||||||
packages = with pkgs; [
|
nodePackages,
|
||||||
rustToolchain
|
}:
|
||||||
rust-analyzer
|
let
|
||||||
|
mainPkg = callPackage ./yazi.nix { };
|
||||||
|
in
|
||||||
|
mainPkg.overrideAttrs (oa: {
|
||||||
|
nativeBuildInputs = [
|
||||||
|
(rust-bin.stable.latest.default.override {
|
||||||
|
extensions = [
|
||||||
|
"rustfmt"
|
||||||
|
"rust-analyzer"
|
||||||
|
"clippy"
|
||||||
|
];
|
||||||
|
})
|
||||||
|
|
||||||
nodePackages.cspell
|
nodePackages.cspell
|
||||||
|
] ++ (oa.nativeBuildInputs or [ ]);
|
||||||
|
|
||||||
file
|
env.RUST_BACKTRACE = "1";
|
||||||
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";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,67 +1,86 @@
|
||||||
{
|
{
|
||||||
makeRustPlatform,
|
rustPlatform,
|
||||||
rustToolchain,
|
|
||||||
version ? "git",
|
version ? "git",
|
||||||
rev,
|
rev ? "unknown",
|
||||||
date,
|
date ? "19700101",
|
||||||
lib,
|
lib,
|
||||||
|
|
||||||
installShellFiles,
|
installShellFiles,
|
||||||
stdenv,
|
stdenv,
|
||||||
darwin,
|
darwin,
|
||||||
|
rust-jemalloc-sys,
|
||||||
|
|
||||||
imagemagick,
|
imagemagick,
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
src = lib.fileset.toSource {
|
||||||
|
root = ../.;
|
||||||
|
fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ../.)) (
|
||||||
|
lib.fileset.unions [
|
||||||
|
../assets
|
||||||
|
../yazi-adapter
|
||||||
|
../yazi-boot
|
||||||
|
../yazi-cli
|
||||||
|
../yazi-config
|
||||||
|
../yazi-core
|
||||||
|
../yazi-dds
|
||||||
|
../yazi-fm
|
||||||
|
../yazi-plugin
|
||||||
|
../yazi-proxy
|
||||||
|
../yazi-scheduler
|
||||||
|
../yazi-shared
|
||||||
|
../Cargo.toml
|
||||||
|
../Cargo.lock
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
in
|
||||||
|
rustPlatform.buildRustPackage rec {
|
||||||
|
pname = "yazi";
|
||||||
|
inherit version src;
|
||||||
|
|
||||||
(makeRustPlatform {
|
cargoLock = {
|
||||||
cargo = rustToolchain;
|
lockFile = "${src}/Cargo.lock";
|
||||||
rustc = rustToolchain;
|
outputHashes = {
|
||||||
}).buildRustPackage
|
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
||||||
{
|
|
||||||
pname = "yazi";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = ../.;
|
|
||||||
|
|
||||||
cargoLock = {
|
|
||||||
lockFile = ../Cargo.lock;
|
|
||||||
outputHashes = {
|
|
||||||
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
YAZI_GEN_COMPLETIONS = true;
|
YAZI_GEN_COMPLETIONS = true;
|
||||||
VERGEN_GIT_SHA = rev;
|
VERGEN_GIT_SHA = rev;
|
||||||
VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
|
VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
installShellFiles
|
installShellFiles
|
||||||
imagemagick
|
imagemagick
|
||||||
];
|
];
|
||||||
buildInputs = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
|
||||||
|
|
||||||
postInstall = ''
|
buildInputs = [
|
||||||
installShellCompletion --cmd yazi \
|
rust-jemalloc-sys
|
||||||
--bash ./yazi-boot/completions/yazi.bash \
|
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||||
--fish ./yazi-boot/completions/yazi.fish \
|
|
||||||
--zsh ./yazi-boot/completions/_yazi
|
|
||||||
|
|
||||||
# Resize logo
|
postInstall = ''
|
||||||
for RES in 16 24 32 48 64 128 256; do
|
installShellCompletion --cmd yazi \
|
||||||
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
|
--bash ./yazi-boot/completions/yazi.bash \
|
||||||
magick assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
--fish ./yazi-boot/completions/yazi.fish \
|
||||||
done
|
--zsh ./yazi-boot/completions/_yazi
|
||||||
|
|
||||||
mkdir -p $out/share/applications
|
# Resize logo
|
||||||
install -m644 assets/yazi.desktop $out/share/applications/
|
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 = {
|
mkdir -p $out/share/applications
|
||||||
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
|
install -m644 assets/yazi.desktop $out/share/applications/
|
||||||
homepage = "https://github.com/sxyazi/yazi";
|
'';
|
||||||
license = lib.licenses.mit;
|
|
||||||
mainProgram = "yazi";
|
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,
|
lib,
|
||||||
|
formats,
|
||||||
runCommand,
|
runCommand,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
|
|
||||||
|
extraPackages ? [ ],
|
||||||
|
optionalDeps ? [
|
||||||
|
jq
|
||||||
|
poppler_utils
|
||||||
|
unar
|
||||||
|
ffmpegthumbnailer
|
||||||
|
fd
|
||||||
|
ripgrep
|
||||||
|
fzf
|
||||||
|
zoxide
|
||||||
|
],
|
||||||
|
|
||||||
|
# deps
|
||||||
|
file,
|
||||||
yazi-unwrapped,
|
yazi-unwrapped,
|
||||||
|
|
||||||
withFile ? true,
|
# optional deps
|
||||||
file,
|
|
||||||
withJq ? true,
|
|
||||||
jq,
|
jq,
|
||||||
withPoppler ? true,
|
|
||||||
poppler_utils,
|
poppler_utils,
|
||||||
withUnar ? true,
|
|
||||||
unar,
|
unar,
|
||||||
withFfmpegthumbnailer ? true,
|
|
||||||
ffmpegthumbnailer,
|
ffmpegthumbnailer,
|
||||||
withFd ? true,
|
|
||||||
fd,
|
fd,
|
||||||
withRipgrep ? true,
|
|
||||||
ripgrep,
|
ripgrep,
|
||||||
withFzf ? true,
|
|
||||||
fzf,
|
fzf,
|
||||||
withZoxide ? true,
|
|
||||||
zoxide,
|
zoxide,
|
||||||
}:
|
|
||||||
|
|
||||||
|
settings ? { },
|
||||||
|
plugins ? { },
|
||||||
|
flavors ? { },
|
||||||
|
initLua ? null,
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib) optional makeBinPath;
|
inherit (lib)
|
||||||
runtimePaths =
|
concatStringsSep
|
||||||
optional withFile file
|
concatMapStringsSep
|
||||||
++ optional withJq jq
|
optionalString
|
||||||
++ optional withPoppler poppler_utils
|
makeBinPath
|
||||||
++ optional withUnar unar
|
mapAttrsToList
|
||||||
++ optional withFfmpegthumbnailer ffmpegthumbnailer
|
;
|
||||||
++ optional withFd fd
|
|
||||||
++ optional withRipgrep ripgrep
|
runtimePaths = [ file ] ++ optionalDeps ++ extraPackages;
|
||||||
++ optional withFzf fzf
|
|
||||||
++ optional withZoxide zoxide;
|
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
|
in
|
||||||
runCommand yazi-unwrapped.name
|
runCommand yazi-unwrapped.name
|
||||||
{
|
{
|
||||||
|
|
@ -48,5 +96,6 @@ runCommand yazi-unwrapped.name
|
||||||
ln -s ${yazi-unwrapped}/share $out/share
|
ln -s ${yazi-unwrapped}/share $out/share
|
||||||
ln -s ${yazi-unwrapped}/bin/ya $out/bin/ya
|
ln -s ${yazi-unwrapped}/bin/ya $out/bin/ya
|
||||||
makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \
|
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…
Add table
Reference in a new issue