mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
refactor(nix): cleanup and switch to nixfmt-rfc-style (#1376)
Co-authored-by: Isabel <isabel@isabelroses.com>
This commit is contained in:
parent
bb29e238b5
commit
c7b002581a
4 changed files with 128 additions and 112 deletions
59
flake.nix
59
flake.nix
|
|
@ -11,48 +11,51 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils, rust-overlay, ... }@inputs:
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
rust-overlay,
|
||||||
|
...
|
||||||
|
}@inputs:
|
||||||
let
|
let
|
||||||
# Nixpkgs overlays
|
# Nixpkgs overlays
|
||||||
overlays = [
|
overlays = [
|
||||||
rust-overlay.overlays.default
|
rust-overlay.overlays.default
|
||||||
(final: prev: {
|
(final: _: {
|
||||||
rustToolchain = final.rust-bin.stable.latest.default.override {
|
rustToolchain = final.rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; };
|
||||||
extensions = [ "rust-src" ];
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
flake-utils.lib.eachDefaultSystem
|
flake-utils.lib.eachDefaultSystem (
|
||||||
(system:
|
system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system overlays; };
|
pkgs = import nixpkgs { inherit system overlays; };
|
||||||
rev = self.shortRev or "dirty";
|
rev = self.shortRev or "dirty";
|
||||||
date = (self.lastModifiedDate or self.lastModified or "19700101");
|
date = self.lastModifiedDate or self.lastModified or "19700101";
|
||||||
version = (builtins.fromTOML
|
version =
|
||||||
(builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
(builtins.fromTOML (builtins.readFile ./yazi-fm/Cargo.toml)).package.version
|
||||||
+ "pre${builtins.substring 0 8 date}_${rev}";
|
+ "pre${builtins.substring 0 8 date}_${rev}";
|
||||||
|
|
||||||
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
|
yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; };
|
||||||
yazi = pkgs.callPackage ./nix/yazi.nix { inherit yazi-unwrapped; };
|
yazi = pkgs.callPackage ./nix/yazi.nix { inherit yazi-unwrapped; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
inherit yazi-unwrapped yazi;
|
inherit yazi-unwrapped yazi;
|
||||||
default = yazi;
|
default = yazi;
|
||||||
};
|
};
|
||||||
|
|
||||||
formatter = pkgs.nixpkgs-fmt;
|
formatter = pkgs.nixfmt-rfc-style;
|
||||||
|
|
||||||
devShells.default = import ./nix/shell.nix { inherit pkgs inputs; };
|
devShells.default = import ./nix/shell.nix { inherit pkgs inputs; };
|
||||||
})
|
}
|
||||||
|
)
|
||||||
// {
|
// {
|
||||||
overlays = rec {
|
overlays = rec {
|
||||||
default = yazi;
|
default = yazi;
|
||||||
yazi = final: prev: {
|
yazi = final: _: { inherit (self.packages."${final.system}") yazi yazi-unwrapped; };
|
||||||
yazi-unwrapped = self.packages."${final.system}".yazi-unwrapped;
|
|
||||||
yazi = self.packages."${final.system}".yazi;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,11 @@ pkgs.mkShell {
|
||||||
zoxide
|
zoxide
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = with pkgs;
|
buildInputs =
|
||||||
lib.optionals stdenv.isDarwin
|
with pkgs;
|
||||||
(with darwin.apple_sdk.frameworks; [ Foundation ]);
|
lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||||
|
|
||||||
env = { RUST_BACKTRACE = "1"; };
|
env = {
|
||||||
|
RUST_BACKTRACE = "1";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,67 @@
|
||||||
{ makeRustPlatform
|
{
|
||||||
, rustToolchain
|
makeRustPlatform,
|
||||||
, version ? "git"
|
rustToolchain,
|
||||||
, rev
|
version ? "git",
|
||||||
, date
|
rev,
|
||||||
, lib
|
date,
|
||||||
|
lib,
|
||||||
|
|
||||||
, installShellFiles
|
installShellFiles,
|
||||||
, stdenv
|
stdenv,
|
||||||
, darwin
|
darwin,
|
||||||
|
|
||||||
, imagemagick
|
imagemagick,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
(makeRustPlatform { cargo = rustToolchain; rustc = rustToolchain; }).buildRustPackage rec {
|
(makeRustPlatform {
|
||||||
pname = "yazi";
|
cargo = rustToolchain;
|
||||||
inherit version rev;
|
rustc = rustToolchain;
|
||||||
|
}).buildRustPackage
|
||||||
|
{
|
||||||
|
pname = "yazi";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
src = ../.;
|
src = ../.;
|
||||||
|
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ../Cargo.lock;
|
lockFile = ../Cargo.lock;
|
||||||
outputHashes = {
|
outputHashes = {
|
||||||
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
env.YAZI_GEN_COMPLETIONS = true;
|
env = {
|
||||||
env.VERGEN_GIT_SHA = rev;
|
YAZI_GEN_COMPLETIONS = true;
|
||||||
env.VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
|
VERGEN_GIT_SHA = rev;
|
||||||
|
VERGEN_BUILD_DATE = builtins.concatStringsSep "-" (builtins.match "(.{4})(.{2})(.{2}).*" date);
|
||||||
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ installShellFiles imagemagick ];
|
nativeBuildInputs = [
|
||||||
buildInputs = lib.optionals stdenv.isDarwin (
|
installShellFiles
|
||||||
with darwin.apple_sdk.frameworks; [ Foundation ]
|
imagemagick
|
||||||
);
|
];
|
||||||
|
buildInputs = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
installShellCompletion --cmd yazi \
|
installShellCompletion --cmd yazi \
|
||||||
--bash ./yazi-boot/completions/yazi.bash \
|
--bash ./yazi-boot/completions/yazi.bash \
|
||||||
--fish ./yazi-boot/completions/yazi.fish \
|
--fish ./yazi-boot/completions/yazi.fish \
|
||||||
--zsh ./yazi-boot/completions/_yazi
|
--zsh ./yazi-boot/completions/_yazi
|
||||||
|
|
||||||
# Resize logo
|
# Resize logo
|
||||||
for RES in 16 24 32 48 64 128 256; do
|
for RES in 16 24 32 48 64 128 256; do
|
||||||
mkdir -p $out/share/icons/hicolor/"$RES"x"$RES"/apps
|
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
|
magick assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
||||||
done
|
done
|
||||||
|
|
||||||
mkdir -p $out/share/applications
|
mkdir -p $out/share/applications
|
||||||
install -m644 assets/yazi.desktop $out/share/applications/
|
install -m644 assets/yazi.desktop $out/share/applications/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with lib; {
|
meta = {
|
||||||
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
|
description = "Blazing fast terminal file manager written in Rust, based on async I/O";
|
||||||
homepage = "https://github.com/sxyazi/yazi";
|
homepage = "https://github.com/sxyazi/yazi";
|
||||||
license = licenses.mit;
|
license = lib.licenses.mit;
|
||||||
mainProgram = "yazi";
|
mainProgram = "yazi";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
71
nix/yazi.nix
71
nix/yazi.nix
|
|
@ -1,31 +1,33 @@
|
||||||
{ lib
|
{
|
||||||
, runCommand
|
lib,
|
||||||
, makeWrapper
|
runCommand,
|
||||||
, yazi-unwrapped
|
makeWrapper,
|
||||||
|
yazi-unwrapped,
|
||||||
|
|
||||||
, withFile ? true
|
withFile ? true,
|
||||||
, file
|
file,
|
||||||
, withJq ? true
|
withJq ? true,
|
||||||
, jq
|
jq,
|
||||||
, withPoppler ? true
|
withPoppler ? true,
|
||||||
, poppler_utils
|
poppler_utils,
|
||||||
, withUnar ? true
|
withUnar ? true,
|
||||||
, unar
|
unar,
|
||||||
, withFfmpegthumbnailer ? true
|
withFfmpegthumbnailer ? true,
|
||||||
, ffmpegthumbnailer
|
ffmpegthumbnailer,
|
||||||
, withFd ? true
|
withFd ? true,
|
||||||
, fd
|
fd,
|
||||||
, withRipgrep ? true
|
withRipgrep ? true,
|
||||||
, ripgrep
|
ripgrep,
|
||||||
, withFzf ? true
|
withFzf ? true,
|
||||||
, fzf
|
fzf,
|
||||||
, withZoxide ? true
|
withZoxide ? true,
|
||||||
, zoxide
|
zoxide,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
runtimePaths = with lib; [ ]
|
inherit (lib) optional makeBinPath;
|
||||||
++ optional withFile file
|
runtimePaths =
|
||||||
|
optional withFile file
|
||||||
++ optional withJq jq
|
++ optional withJq jq
|
||||||
++ optional withPoppler poppler_utils
|
++ optional withPoppler poppler_utils
|
||||||
++ optional withUnar unar
|
++ optional withUnar unar
|
||||||
|
|
@ -36,14 +38,15 @@ let
|
||||||
++ optional withZoxide zoxide;
|
++ optional withZoxide zoxide;
|
||||||
in
|
in
|
||||||
runCommand yazi-unwrapped.name
|
runCommand yazi-unwrapped.name
|
||||||
{
|
{
|
||||||
inherit (yazi-unwrapped) pname version meta;
|
inherit (yazi-unwrapped) pname version meta;
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
} ''
|
}
|
||||||
mkdir -p $out/bin
|
''
|
||||||
ln -s ${yazi-unwrapped}/share $out/share
|
mkdir -p $out/bin
|
||||||
ln -s ${yazi-unwrapped}/bin/ya $out/bin/ya
|
ln -s ${yazi-unwrapped}/share $out/share
|
||||||
makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \
|
ln -s ${yazi-unwrapped}/bin/ya $out/bin/ya
|
||||||
--prefix PATH : "${lib.makeBinPath runtimePaths}"
|
makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \
|
||||||
''
|
--prefix PATH : "${makeBinPath runtimePaths}"
|
||||||
|
''
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue