From d42c42b164b670152d96289fe2cf455d3010deb7 Mon Sep 17 00:00:00 2001 From: eljamm Date: Wed, 19 Jun 2024 17:55:18 +0100 Subject: [PATCH 1/2] yazi: add eljamm as maintainer --- pkgs/by-name/ya/yazi-unwrapped/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/ya/yazi-unwrapped/package.nix b/pkgs/by-name/ya/yazi-unwrapped/package.nix index 77a9b9ad8b5bb..7f536d92674cb 100644 --- a/pkgs/by-name/ya/yazi-unwrapped/package.nix +++ b/pkgs/by-name/ya/yazi-unwrapped/package.nix @@ -44,7 +44,7 @@ rustPlatform.buildRustPackage rec { description = "Blazing fast terminal file manager written in Rust, based on async I/O"; homepage = "https://github.com/sxyazi/yazi"; license = lib.licenses.mit; - maintainers = with lib.maintainers; [ xyenon matthiasbeyer linsui ]; + maintainers = with lib.maintainers; [ xyenon matthiasbeyer linsui eljamm ]; mainProgram = "yazi"; }; } From 1f6b8d25b8b364908ca2aeac3bfc4b9ebb7d6aa4 Mon Sep 17 00:00:00 2001 From: eljamm Date: Thu, 20 Jun 2024 11:05:47 +0100 Subject: [PATCH 2/2] yazi: clean up wrapper, add options and format - Remove redundant `withX` options - Add `optionalDeps`: packages that provide additional features - Add `extraPackages`: user-defined packages - Format with nixfmt --- pkgs/by-name/ya/yazi/package.nix | 152 ++++++++++++++++--------------- 1 file changed, 78 insertions(+), 74 deletions(-) diff --git a/pkgs/by-name/ya/yazi/package.nix b/pkgs/by-name/ya/yazi/package.nix index 276d0251710b5..66d74e019d20c 100644 --- a/pkgs/by-name/ya/yazi/package.nix +++ b/pkgs/by-name/ya/yazi/package.nix @@ -1,89 +1,93 @@ -{ lib -, runCommand -, makeWrapper -, yazi-unwrapped +{ + lib, + formats, + runCommand, + makeWrapper, + + extraPackages ? [ ], + optionalDeps ? [ + jq + poppler_utils + unar + ffmpegthumbnailer + fd + ripgrep + fzf + zoxide + ], + + # deps + file, + yazi-unwrapped, -, withRuntimeDeps ? true -, 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 -, settings ? { } -, formats -, plugins ? { } -, flavors ? { } -, initLua ? null + # optional deps + jq, + poppler_utils, + unar, + ffmpegthumbnailer, + fd, + ripgrep, + fzf, + zoxide, + + settings ? { }, + plugins ? { }, + flavors ? { }, + initLua ? null, }: let - runtimePaths = with lib; - [ ] - ++ 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; + runtimePaths = [ file ] ++ optionalDeps ++ extraPackages; settingsFormat = formats.toml { }; - files = [ "yazi" "theme" "keymap" ]; + files = [ + "yazi" + "theme" + "keymap" + ]; - configHome = if (settings == { } && initLua == null && plugins == { } && flavors == { }) then null else - runCommand "YAZI_CONFIG_HOME" { } '' - mkdir -p $out - ${lib.concatMapStringsSep - "\n" - (name: lib.optionalString (settings ? ${name} && settings.${name} != { }) '' - ln -s ${settingsFormat.generate "${name}.toml" settings.${name}} $out/${name}.toml - '') - files} + configHome = + if (settings == { } && initLua == null && plugins == { } && flavors == { }) then + null + else + runCommand "YAZI_CONFIG_HOME" { } '' + mkdir -p $out + ${lib.concatMapStringsSep "\n" ( + name: + lib.optionalString (settings ? ${name} && settings.${name} != { }) '' + ln -s ${settingsFormat.generate "${name}.toml" settings.${name}} $out/${name}.toml + '' + ) files} - mkdir $out/plugins - ${lib.optionalString (plugins != { }) '' - ${lib.concatStringsSep - "\n" - (lib.mapAttrsToList (name: value: "ln -s ${value} $out/plugins/${name}") plugins)} - ''} + mkdir $out/plugins + ${lib.optionalString (plugins != { }) '' + ${lib.concatStringsSep "\n" ( + lib.mapAttrsToList (name: value: "ln -s ${value} $out/plugins/${name}") plugins + )} + ''} - mkdir $out/flavors - ${lib.optionalString (flavors != { }) '' - ${lib.concatStringsSep - "\n" - (lib.mapAttrsToList (name: value: "ln -s ${value} $out/flavors/${name}") flavors)} - ''} + mkdir $out/flavors + ${lib.optionalString (flavors != { }) '' + ${lib.concatStringsSep "\n" ( + lib.mapAttrsToList (name: value: "ln -s ${value} $out/flavors/${name}") flavors + )} + ''} - ${lib.optionalString (initLua != null) "ln -s ${initLua} $out/init.lua"} - ''; + ${lib.optionalString (initLua != null) "ln -s ${initLua} $out/init.lua"} + ''; in -if (!withRuntimeDeps && configHome == null) then yazi-unwrapped else 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 - makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \ - ${lib.optionalString withRuntimeDeps "--prefix PATH : \"${lib.makeBinPath runtimePaths}\""} \ - ${lib.optionalString (configHome != null) "--set YAZI_CONFIG_HOME ${configHome}"} -'' + nativeBuildInputs = [ makeWrapper ]; + } + '' + mkdir -p $out/bin + ln -s ${yazi-unwrapped}/share $out/share + makeWrapper ${yazi-unwrapped}/bin/yazi $out/bin/yazi \ + --prefix PATH : ${lib.makeBinPath runtimePaths} \ + ${lib.optionalString (configHome != null) "--set YAZI_CONFIG_HOME ${configHome}"} + ''