Loading nixos/modules/programs/yazi.nix +56 −5 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ let settingsFormat = pkgs.formats.toml { }; names = [ "yazi" "theme" "keymap" ]; files = [ "yazi" "theme" "keymap" ]; dirs = [ "plugins" "flavors" ]; in { options.programs.yazi = { Loading @@ -15,7 +17,7 @@ in settings = lib.mkOption { type = with lib.types; submodule { options = lib.listToAttrs (map options = (lib.listToAttrs (map (name: lib.nameValuePair name (lib.mkOption { inherit (settingsFormat) type; default = { }; Loading @@ -25,24 +27,73 @@ in See https://yazi-rs.github.io/docs/configuration/${name}/ for documentation. ''; })) names); files)); }; default = { }; description = '' Configuration included in `$YAZI_CONFIG_HOME`. ''; }; initLua = lib.mkOption { type = with lib.types; nullOr path; default = null; description = '' The init.lua for Yazi itself. ''; }; } // (lib.listToAttrs (map (name: lib.nameValuePair name (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. ''; })) dirs) ); flavors = lib.mkOption { type = with lib.types; attrsOf (oneOf [ path package ]); default = { }; description = '' Pre-made themes. See https://yazi-rs.github.io/docs/flavors/overview/ for documentation. ''; example = lib.literalExpression '' { foo = ./foo; bar = pkgs.bar; } ''; }; }; config = lib.mkIf cfg.enable { environment = { systemPackages = [ cfg.package ]; variables.YAZI_CONFIG_HOME = "/etc/yazi/"; etc = lib.attrsets.mergeAttrsList (map etc = (lib.attrsets.mergeAttrsList (map (name: lib.optionalAttrs (cfg.settings.${name} != { }) { "yazi/${name}.toml".source = settingsFormat.generate "${name}.toml" cfg.settings.${name}; }) names); 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; }; }; }; meta = { Loading Loading
nixos/modules/programs/yazi.nix +56 −5 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ let settingsFormat = pkgs.formats.toml { }; names = [ "yazi" "theme" "keymap" ]; files = [ "yazi" "theme" "keymap" ]; dirs = [ "plugins" "flavors" ]; in { options.programs.yazi = { Loading @@ -15,7 +17,7 @@ in settings = lib.mkOption { type = with lib.types; submodule { options = lib.listToAttrs (map options = (lib.listToAttrs (map (name: lib.nameValuePair name (lib.mkOption { inherit (settingsFormat) type; default = { }; Loading @@ -25,24 +27,73 @@ in See https://yazi-rs.github.io/docs/configuration/${name}/ for documentation. ''; })) names); files)); }; default = { }; description = '' Configuration included in `$YAZI_CONFIG_HOME`. ''; }; initLua = lib.mkOption { type = with lib.types; nullOr path; default = null; description = '' The init.lua for Yazi itself. ''; }; } // (lib.listToAttrs (map (name: lib.nameValuePair name (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. ''; })) dirs) ); flavors = lib.mkOption { type = with lib.types; attrsOf (oneOf [ path package ]); default = { }; description = '' Pre-made themes. See https://yazi-rs.github.io/docs/flavors/overview/ for documentation. ''; example = lib.literalExpression '' { foo = ./foo; bar = pkgs.bar; } ''; }; }; config = lib.mkIf cfg.enable { environment = { systemPackages = [ cfg.package ]; variables.YAZI_CONFIG_HOME = "/etc/yazi/"; etc = lib.attrsets.mergeAttrsList (map etc = (lib.attrsets.mergeAttrsList (map (name: lib.optionalAttrs (cfg.settings.${name} != { }) { "yazi/${name}.toml".source = settingsFormat.generate "${name}.toml" cfg.settings.${name}; }) names); 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; }; }; }; meta = { Loading