From 8039c4f9ab97e8561d5e18e06c5f9f0b344f82c3 Mon Sep 17 00:00:00 2001 From: "Martin J. Andersen" <69694841+Martin-Joe@users.noreply.github.com> Date: Sat, 1 Nov 2025 14:26:54 +0100 Subject: [PATCH] modules/yazi: init Co-authored-by: holly --- modules/yazi/check.nix | 14 ++++++ modules/yazi/module.nix | 98 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 modules/yazi/check.nix create mode 100644 modules/yazi/module.nix diff --git a/modules/yazi/check.nix b/modules/yazi/check.nix new file mode 100644 index 00000000..889cb61a --- /dev/null +++ b/modules/yazi/check.nix @@ -0,0 +1,14 @@ +{ + pkgs, + self, +}: +let + yaziWrapped = + (self.wrapperModules.yazi.apply { + inherit pkgs; + }).wrapper; +in +pkgs.runCommand "yazi-test" { } '' + "${yaziWrapped}/bin/yazi" --version | grep -q "${yaziWrapped.version}" + touch $out +'' diff --git a/modules/yazi/module.nix b/modules/yazi/module.nix new file mode 100644 index 00000000..adf61589 --- /dev/null +++ b/modules/yazi/module.nix @@ -0,0 +1,98 @@ +{ + wlib, + lib, + config, + ... +}: +let + tomlFmt = config.pkgs.formats.toml { }; +in +{ + options = { + settings = lib.mkOption { + type = tomlFmt.type; + default = { }; + description = '' + General settings. + See + ''; + }; + + keymap = lib.mkOption { + type = tomlFmt.type; + default = { }; + description = '' + Keymap settings. + See + ''; + }; + + theme = lib.mkOption { + type = tomlFmt.type; + default = { }; + description = '' + Theming. + See + ''; + }; + + "yazi.toml" = lib.mkOption { + type = wlib.types.file config.pkgs; + default.path = tomlFmt.generate "yazi.toml" config.settings; + }; + "keymap.toml" = lib.mkOption { + type = wlib.types.file config.pkgs; + default.path = tomlFmt.generate "keymap.toml" config.keymap; + }; + "theme.toml" = lib.mkOption { + type = wlib.types.file config.pkgs; + default.path = tomlFmt.generate "theme.toml" config.theme; + }; + + extraFiles = lib.mkOption { + type = lib.types.listOf ( + lib.types.submodule { + options = { + name = lib.mkOption { + type = lib.types.nonEmptyStr; + description = "File name in the config directory"; + }; + file = lib.mkOption { + type = wlib.types.file config.pkgs; + description = "File or path to add into the config directory"; + }; + }; + } + ); + default = [ ]; + description = "Additional files to be placed in the config directory"; + }; + }; + + config = { + package = lib.mkDefault config.pkgs.yazi; + env.YAZI_CONFIG_HOME = toString ( + config.pkgs.linkFarm "yazi-merged-config" ( + let + entry = name: path: { inherit name path; }; + in + [ + (entry "yazi.toml" config."yazi.toml".path) + (entry "keymap.toml" config."keymap.toml".path) + (entry "theme.toml" config."theme.toml".path) + ] + ++ (map (f: { + inherit (f) name; + path = f.file.path; + }) config.extraFiles) + ) + ); + meta.maintainers = [ + { + name = "holly"; + github = "hollymlem"; + githubId = 35699052; + } + ]; + }; +}