refactor(nix): cleanup and switch to nixfmt-rfc-style (#1376)

Co-authored-by: Isabel <isabel@isabelroses.com>
This commit is contained in:
uncenter 2024-07-31 23:01:07 -04:00 committed by GitHub
parent bb29e238b5
commit c7b002581a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 128 additions and 112 deletions

View file

@ -11,26 +11,31 @@
};
};
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:
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
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; };
@ -42,17 +47,15 @@
default = yazi;
};
formatter = pkgs.nixpkgs-fmt;
formatter = pkgs.nixfmt-rfc-style;
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; };
};
};
}

View file

@ -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";
};
}

View file

@ -1,20 +1,25 @@
{ 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 {
(makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
}).buildRustPackage
{
pname = "yazi";
inherit version rev;
inherit version;
src = ../.;
@ -25,14 +30,17 @@
};
};
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 \
@ -50,10 +58,10 @@
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";
homepage = "https://github.com/sxyazi/yazi";
license = licenses.mit;
license = lib.licenses.mit;
mainProgram = "yazi";
};
}

View file

@ -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
@ -40,10 +42,11 @@ runCommand yazi-unwrapped.name
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}"
--prefix PATH : "${makeBinPath runtimePaths}"
''