From 12d1e66cfd60a7d1bb40e67c3e971b3a929091da 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 --- modules/yazi/check.nix | 16 ++++++++++ modules/yazi/module.nix | 65 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 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 0000000..515bbdc --- /dev/null +++ b/modules/yazi/check.nix @@ -0,0 +1,16 @@ +{ + 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 0000000..5b902e4 --- /dev/null +++ b/modules/yazi/module.nix @@ -0,0 +1,65 @@ +{ + wlib, + lib, + ... +}: +wlib.wrapModule ( + { config, ... }: + let + tomlFmt = config.pkgs.formats.toml { }; + in + { + options = { + settings = lib.mkOption { + type = tomlFmt.type; + default = { }; + description = '' + Yazi configuration for yazi.toml. + See https://yazi-rs.github.io/docs/configuration/yazi + ''; + }; + + keymap = lib.mkOption { + type = tomlFmt.type; + default = { }; + description = '' + Yazi configuration for keymap.toml. + See + ''; + }; + + theme = lib.mkOption { + type = tomlFmt.type; + default = { }; + description = '' + Yazi configuration for theme.toml. + See + ''; + }; + + extraFlags = lib.mkOption { + type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling + default = { }; + description = "Extra flags to pass to yazi."; + }; + }; + + config = + let + settingsToml = tomlFmt.generate "yazi.toml" config.settings; + keymapToml = tomlFmt.generate "keymap.toml" config.keymap; + themeToml = tomlFmt.generate "theme.toml" config.theme; + + yaziConfigDir = config.pkgs.linkFarmFromDrvs "yazi-config-directory" [ + settingsToml + keymapToml + themeToml + ]; + in + { + flags = config.extraFlags; + package = lib.mkDefault config.pkgs.yazi; + env.YAZI_CONFIG_HOME = "${yaziConfigDir}"; + }; + } +)