Skip to content

Commit

Permalink
yazi: allow literal string for initLua
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter authored Jul 3, 2024
1 parent 269cc18 commit e915831
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/programs/yazi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions tests/modules/programs/yazi/default.nix
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
14 changes: 14 additions & 0 deletions tests/modules/programs/yazi/init-lua-string.nix
Original file line number Diff line number Diff line change
@@ -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}
'';
}

0 comments on commit e915831

Please sign in to comment.