mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01: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
|
||||
# Nixpkgs overlays
|
||||
overlays = [
|
||||
rust-overlay.overlays.default
|
||||
(final: prev: {
|
||||
rustToolchain = final.rust-bin.stable.latest.default.override {
|
||||
extensions = [ "rust-src" ];
|
||||
};
|
||||
(final: _: {
|
||||
rustToolchain = final.rust-bin.stable.latest.default.override { extensions = [ "rust-src" ]; };
|
||||
})
|
||||
];
|
||||
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
|
||||
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}";
|
||||
|
||||
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;
|
||||
};
|
||||
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;
|
||||
};
|
||||
|
||||
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 {
|
||||
default = yazi;
|
||||
yazi = final: prev: {
|
||||
yazi-unwrapped = self.packages."${final.system}".yazi-unwrapped;
|
||||
yazi = self.packages."${final.system}".yazi;
|
||||
};
|
||||
yazi = final: _: { inherit (self.packages."${final.system}") yazi yazi-unwrapped; };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@ pkgs.mkShell {
|
|||
zoxide
|
||||
];
|
||||
|
||||
buildInputs = with pkgs;
|
||||
lib.optionals stdenv.isDarwin
|
||||
(with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||
buildInputs =
|
||||
with pkgs;
|
||||
lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Foundation ]);
|
||||
|
||||
env = { RUST_BACKTRACE = "1"; };
|
||||
env = {
|
||||
RUST_BACKTRACE = "1";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,59 +1,67 @@
|
|||
{ makeRustPlatform
|
||||
, rustToolchain
|
||||
, version ? "git"
|
||||
, rev
|
||||
, date
|
||||
, lib
|
||||
{
|
||||
makeRustPlatform,
|
||||
rustToolchain,
|
||||
version ? "git",
|
||||
rev,
|
||||
date,
|
||||
lib,
|
||||
|
||||
, installShellFiles
|
||||
, stdenv
|
||||
, darwin
|
||||
installShellFiles,
|
||||
stdenv,
|
||||
darwin,
|
||||
|
||||
, imagemagick
|
||||
imagemagick,
|
||||
}:
|
||||
|
||||
(makeRustPlatform { cargo = rustToolchain; rustc = rustToolchain; }).buildRustPackage rec {
|
||||
pname = "yazi";
|
||||
inherit version rev;
|
||||
(makeRustPlatform {
|
||||
cargo = rustToolchain;
|
||||
rustc = rustToolchain;
|
||||
}).buildRustPackage
|
||||
{
|
||||
pname = "yazi";
|
||||
inherit version;
|
||||
|
||||
src = ../.;
|
||||
src = ../.;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
outputHashes = {
|
||||
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
outputHashes = {
|
||||
"notify-6.1.1" = "sha256-5Ft2yvRPi2EaErcGBkF/3Xv6K7ijFGbdjmSqI4go/h4=";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
env.YAZI_GEN_COMPLETIONS = true;
|
||||
env.VERGEN_GIT_SHA = rev;
|
||||
env.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
|
||||
];
|
||||
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
|
||||
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
|
||||
magick assets/logo.png -resize "$RES"x"$RES" $out/share/icons/hicolor/"$RES"x"$RES"/apps/yazi.png
|
||||
done
|
||||
# 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
|
||||
|
||||
mkdir -p $out/share/applications
|
||||
install -m644 assets/yazi.desktop $out/share/applications/
|
||||
'';
|
||||
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";
|
||||
};
|
||||
}
|
||||
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";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
71
nix/yazi.nix
71
nix/yazi.nix
|
|
@ -1,31 +1,33 @@
|
|||
{ lib
|
||||
, runCommand
|
||||
, makeWrapper
|
||||
, yazi-unwrapped
|
||||
{
|
||||
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
|
||||
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
|
||||
inherit (lib) optional makeBinPath;
|
||||
runtimePaths =
|
||||
optional withFile file
|
||||
++ optional withJq jq
|
||||
++ optional withPoppler poppler_utils
|
||||
++ optional withUnar unar
|
||||
|
|
@ -36,14 +38,15 @@ let
|
|||
++ optional withZoxide zoxide;
|
||||
in
|
||||
runCommand yazi-unwrapped.name
|
||||
{
|
||||
inherit (yazi-unwrapped) pname version meta;
|
||||
{
|
||||
inherit (yazi-unwrapped) pname version meta;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
} ''
|
||||
mkdir -p $out/bin
|
||||
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 : "${lib.makeBinPath runtimePaths}"
|
||||
''
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
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}"
|
||||
''
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue