about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorlinsui <linsui@inbox.lv>2024-04-07 22:54:18 +0800
committerlinsui <linsui555@gmail.com>2024-05-18 01:52:43 +0800
commitced6734812dd664e3a9ef870aafc4d5159bde25d (patch)
tree357ed3e68e7b688083958e2d5dd070943410cfc4 /nixos/modules
parent4826bc455d57af7cd75049ba3bf2f6a414a277bf (diff)
yazi: add config files to wrapper
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/programs/yazi.nix44
1 files changed, 16 insertions, 28 deletions
diff --git a/nixos/modules/programs/yazi.nix b/nixos/modules/programs/yazi.nix
index cfb26c01bfab5..d9f38d8d81185 100644
--- a/nixos/modules/programs/yazi.nix
+++ b/nixos/modules/programs/yazi.nix
@@ -6,8 +6,6 @@ let
   settingsFormat = pkgs.formats.toml { };
 
   files = [ "yazi" "theme" "keymap" ];
-
-  dirs = [ "plugins" "flavors" ];
 in
 {
   options.programs.yazi = {
@@ -41,20 +39,24 @@ in
       description = ''
         The init.lua for Yazi itself.
       '';
+      example = lib.literalExpression "./init.lua";
     };
 
-  } // (lib.listToAttrs (map
-    (name: lib.nameValuePair name (lib.mkOption {
+    plugins = lib.mkOption {
       type = with lib.types; attrsOf (oneOf [ path package ]);
       default = { };
       description = ''
         Lua plugins.
 
-        See https://yazi-rs.github.io/docs/${name}/overview/ for documentation.
+        See https://yazi-rs.github.io/docs/plugins/overview/ for documentation.
       '';
-    }))
-    dirs)
-  );
+      example = lib.literalExpression ''
+        {
+          foo = ./foo;
+          bar = pkgs.bar;
+        }
+      '';
+    };
 
     flavors = lib.mkOption {
       type = with lib.types; attrsOf (oneOf [ path package ]);
@@ -75,27 +77,13 @@ in
   };
 
   config = lib.mkIf cfg.enable {
-    environment = {
-      systemPackages = [ cfg.package ];
-      variables.YAZI_CONFIG_HOME = "/etc/yazi/";
-      etc = (lib.attrsets.mergeAttrsList (map
-        (name: lib.optionalAttrs (cfg.settings.${name} != { }) {
-          "yazi/${name}.toml".source = settingsFormat.generate "${name}.toml" cfg.settings.${name};
-        })
-        files)) // (lib.attrsets.mergeAttrsList (map
-        (dir:
-          if cfg.${dir} != { } then
-            (lib.mapAttrs'
-              (name: value: lib.nameValuePair "yazi/${dir}/${name}" { source = value; })
-              cfg.${dir}) else {
-            # Yazi checks the directories. If they don't exist it tries to create them and then crashes.
-            "yazi/${dir}".source = pkgs.emptyDirectory;
-          })
-        dirs)) // lib.optionalAttrs (cfg.initLua != null) {
-        "yazi/init.lua".source = cfg.initLua;
-      };
-    };
+    environment.systemPackages = [
+      (cfg.package.override {
+        inherit (cfg) settings initLua plugins flavors;
+      })
+    ];
   };
+
   meta = {
     maintainers = with lib.maintainers; [ linsui ];
   };