about summary refs log tree commit diff
path: root/pkgs/by-name/ya/yazi/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/ya/yazi/package.nix')
-rw-r--r--pkgs/by-name/ya/yazi/package.nix45
1 files changed, 43 insertions, 2 deletions
diff --git a/pkgs/by-name/ya/yazi/package.nix b/pkgs/by-name/ya/yazi/package.nix
index 134db023edd96..ee807645c3fd4 100644
--- a/pkgs/by-name/ya/yazi/package.nix
+++ b/pkgs/by-name/ya/yazi/package.nix
@@ -3,6 +3,7 @@
 , makeWrapper
 , yazi-unwrapped
 
+, withRuntimeDeps ? true
 , withFile ? true
 , file
 , withJq ? true
@@ -21,10 +22,16 @@
 , fzf
 , withZoxide ? true
 , zoxide
+, settings ? { }
+, formats
+, plugins ? { }
+, flavors ? { }
+, initLua ? null
 }:
 
 let
-  runtimePaths = with lib; [ ]
+  runtimePaths = with lib;
+    [ ]
     ++ optional withFile file
     ++ optional withJq jq
     ++ optional withPoppler poppler_utils
@@ -34,7 +41,40 @@ let
     ++ optional withRipgrep ripgrep
     ++ 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
+    ${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.concatMapStringsSep
+        "\n"
+        (lib.mapAttrsToList (name: value: "ln -s ${value} $out/plugins/${name}") plugins)}
+    ''}
+
+    mkdir $out/flavors
+    ${lib.optionalString (flavors != { }) ''
+        ${lib.concatMapStringsSep
+        "\n"
+        (lib.mapAttrsToList (name: value: "ln -s ${value} $out/flavors/${name}") flavors)}
+    ''}
+
+
+    ${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;
@@ -44,5 +84,6 @@ runCommand yazi-unwrapped.name
   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 withRuntimeDeps "--prefix PATH : \"${lib.makeBinPath runtimePaths}\""} \
+    ${lib.optionalString (configHome != null) "--set YAZI_CONFIG_HOME ${configHome}"}
 ''