1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-09 12:49:44 +01:00

yazi: allow literal string for initLua

This commit is contained in:
uncenter 2024-07-03 17:36:14 -04:00 committed by GitHub
parent 269cc18d94
commit e915831472
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 2 deletions

View file

@ -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:

View file

@ -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;

View file

@ -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}
'';
}