diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 105bbec4d..d7b880200 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -141,7 +141,7 @@ in { }; initLua = mkOption { - type = with types; nullOr path; + type = with types; nullOr (either path lines); default = null; description = '' The init.lua for Yazi itself. @@ -210,7 +210,12 @@ in { "yazi/theme.toml" = mkIf (cfg.theme != { }) { source = tomlFormat.generate "yazi-theme" cfg.theme; }; - "yazi/init.lua" = mkIf (cfg.initLua != null) { source = cfg.initLua; }; + "yazi/init.lua" = mkIf (cfg.initLua != null) + (if builtins.isPath cfg.initLua then { + source = cfg.initLua; + } else { + text = cfg.initLua; + }); } // (mapAttrs' (name: value: nameValuePair "yazi/flavors/${name}.yazi" { source = value; }) cfg.flavors) // (mapAttrs' (name: value: diff --git a/tests/modules/programs/yazi/default.nix b/tests/modules/programs/yazi/default.nix index 09d52ac3d..ec543c84d 100644 --- a/tests/modules/programs/yazi/default.nix +++ b/tests/modules/programs/yazi/default.nix @@ -1,5 +1,6 @@ { yazi-settings = ./settings.nix; + yazi-init-lua-string = ./init-lua-string.nix; yazi-bash-integration-enabled = ./bash-integration-enabled.nix; yazi-zsh-integration-enabled = ./zsh-integration-enabled.nix; yazi-fish-integration-enabled = ./fish-integration-enabled.nix; diff --git a/tests/modules/programs/yazi/init-lua-string.nix b/tests/modules/programs/yazi/init-lua-string.nix new file mode 100644 index 000000000..999dd6bc6 --- /dev/null +++ b/tests/modules/programs/yazi/init-lua-string.nix @@ -0,0 +1,14 @@ +{ ... }: { + programs.yazi = { + enable = true; + + initLua = builtins.readFile ./init.lua; + }; + + test.stubs.yazi = { }; + + nmt.script = '' + assertFileContent home-files/.config/yazi/init.lua \ + ${./init.lua} + ''; +}