mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
commit
d2f631a96e
10 changed files with 136 additions and 14 deletions
|
@ -145,8 +145,11 @@ in {
|
||||||
default = { };
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
Lua plugins.
|
Lua plugins.
|
||||||
|
Values should be a package or path containing an `init.lua` file.
|
||||||
|
Will be linked to {file}`$XDG_CONFIG_HOME/yazi/plugins/<name>.yazi`.
|
||||||
|
|
||||||
See https://yazi-rs.github.io/docs/plugins/overview/ for documentation.
|
See <https://yazi-rs.github.io/docs/plugins/overview>
|
||||||
|
for documentation.
|
||||||
'';
|
'';
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
{
|
{
|
||||||
|
@ -161,8 +164,10 @@ in {
|
||||||
default = { };
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
Pre-made themes.
|
Pre-made themes.
|
||||||
|
Values should be a package or path containing the required files.
|
||||||
|
Will be linked to {file}`$XDG_CONFIG_HOME/yazi/flavors/<name>.yazi`.
|
||||||
|
|
||||||
See https://yazi-rs.github.io/docs/flavors/overview/ for documentation.
|
See <https://yazi-rs.github.io/docs/flavors/overview/> for documentation.
|
||||||
'';
|
'';
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
{
|
{
|
||||||
|
@ -171,7 +176,6 @@ in {
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -198,10 +202,63 @@ in {
|
||||||
source = tomlFormat.generate "yazi-theme" 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) { source = cfg.initLua; };
|
||||||
} // (mapAttrs'
|
} // (mapAttrs' (name: value:
|
||||||
(name: value: nameValuePair "yazi/plugins/${name}" { source = value; })
|
nameValuePair "yazi/flavors/${name}.yazi" { source = value; })
|
||||||
cfg.plugins) // (mapAttrs'
|
cfg.flavors) // (mapAttrs' (name: value:
|
||||||
(name: value: nameValuePair "yazi/flavors/${name}" { source = value; })
|
nameValuePair "yazi/plugins/${name}.yazi" { source = value; })
|
||||||
cfg.flavors);
|
cfg.plugins);
|
||||||
|
|
||||||
|
warnings = filter (s: s != "") (concatLists [
|
||||||
|
(mapAttrsToList (name: value:
|
||||||
|
optionalString (hasSuffix ".yazi" name) ''
|
||||||
|
Flavors like `programs.yazi.flavors."${name}"` should no longer have the suffix ".yazi" in their attribute name.
|
||||||
|
The flavor will be linked to `$XDG_CONFIG_HOME/yazi/flavors/${name}.yazi`.
|
||||||
|
You probably want to rename it to `programs.yazi.flavors."${
|
||||||
|
removeSuffix ".yazi" name
|
||||||
|
}"`.
|
||||||
|
'') cfg.flavors)
|
||||||
|
(mapAttrsToList (name: value:
|
||||||
|
optionalString (hasSuffix ".yazi" name) ''
|
||||||
|
Plugins like `programs.yazi.plugins."${name}"` should no longer have the suffix ".yazi" in their attribute name.
|
||||||
|
The plugin will be linked to `$XDG_CONFIG_HOME/yazi/plugins/${name}.yazi`.
|
||||||
|
You probably want to rename it to `programs.yazi.plugins."${
|
||||||
|
removeSuffix ".yazi" name
|
||||||
|
}"`.
|
||||||
|
'') cfg.plugins)
|
||||||
|
]);
|
||||||
|
|
||||||
|
assertions = let
|
||||||
|
mkAsserts = opt: requiredFiles:
|
||||||
|
mapAttrsToList (name: value:
|
||||||
|
let
|
||||||
|
isDir = pathIsDirectory "${value}";
|
||||||
|
msgNotDir = optionalString (!isDir)
|
||||||
|
"The path or package should be a directory, not a single file.";
|
||||||
|
isFileMissing = file:
|
||||||
|
!(pathExists "${value}/${file}")
|
||||||
|
|| pathIsDirectory "${value}/${file}";
|
||||||
|
missingFiles = filter isFileMissing requiredFiles;
|
||||||
|
msgFilesMissing = optionalString (missingFiles != [ ])
|
||||||
|
"The ${singularOpt} is missing these files: ${
|
||||||
|
toString missingFiles
|
||||||
|
}";
|
||||||
|
singularOpt = removeSuffix "s" opt;
|
||||||
|
in {
|
||||||
|
assertion = isDir && missingFiles == [ ];
|
||||||
|
message = ''
|
||||||
|
Value at `programs.yazi.${opt}.${name}` is not a valid yazi ${singularOpt}.
|
||||||
|
${msgNotDir}
|
||||||
|
${msgFilesMissing}
|
||||||
|
Evaluated value: `${value}`
|
||||||
|
'';
|
||||||
|
}) cfg.${opt};
|
||||||
|
in (mkAsserts "flavors" [
|
||||||
|
"flavor.toml"
|
||||||
|
"tmtheme.xml"
|
||||||
|
"README.md"
|
||||||
|
"preview.png"
|
||||||
|
"LICENSE"
|
||||||
|
"LICENSE-tmtheme"
|
||||||
|
]) ++ (mkAsserts "plugins" [ "init.lua" ]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
0
tests/modules/programs/yazi/empty/.gitkeep
Normal file
0
tests/modules/programs/yazi/empty/.gitkeep
Normal file
0
tests/modules/programs/yazi/flavor/LICENSE
Normal file
0
tests/modules/programs/yazi/flavor/LICENSE
Normal file
0
tests/modules/programs/yazi/flavor/LICENSE-tmtheme
Normal file
0
tests/modules/programs/yazi/flavor/LICENSE-tmtheme
Normal file
50
tests/modules/programs/yazi/flavor/README.md
Normal file
50
tests/modules/programs/yazi/flavor/README.md
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/sxyazi/yazi/blob/main/assets/logo.png?raw=true" alt="Yazi logo" width="20%">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3 align="center">
|
||||||
|
Example Flavor for <a href="https://github.com/sxyazi/yazi">Yazi</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
## Cooking up a new flavor
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Please remove this section from your README before publishing.
|
||||||
|
|
||||||
|
1. [x] Fork this repository and rename it to `your-flavor-name.yazi`.
|
||||||
|
2. [ ] Copy the **parts you need to customize** from the [default theme.toml](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/theme.toml) as `./flavor.toml`, and change them to meet your preferences.
|
||||||
|
3. [ ] Find a `.tmTheme` file on GitHub that matches the color of your flavor, copy it and it's license file as `./tmtheme.xml`, and `LICENSE-tmtheme`.
|
||||||
|
4. [ ] Modify the content and preview image in the README to fit your flavor.
|
||||||
|
|
||||||
|
## 👀 Preview
|
||||||
|
|
||||||
|
<img src="preview.png" width="600" />
|
||||||
|
|
||||||
|
## 🎨 Installation
|
||||||
|
|
||||||
|
<!-- Please replace "username/example.yazi" with your repository name. -->
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Linux/macOS
|
||||||
|
git clone https://github.com/username/example.yazi.git ~/.config/yazi/flavors/example.yazi
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
git clone https://github.com/username/example.yazi.git %AppData%\yazi\config\flavors\example.yazi
|
||||||
|
```
|
||||||
|
|
||||||
|
## ⚙️ Usage
|
||||||
|
|
||||||
|
Add the these lines to your `theme.toml` configuration file to use it:
|
||||||
|
|
||||||
|
<!-- Please replace "example" with your flavor name. -->
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[flavor]
|
||||||
|
use = "example"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📜 License
|
||||||
|
|
||||||
|
The flavor is MIT-licensed, and the included tmTheme is also MIT-licensed.
|
||||||
|
|
||||||
|
Check the [LICENSE](LICENSE) and [LICENSE-tmtheme](LICENSE-tmtheme) file for more details.
|
2
tests/modules/programs/yazi/flavor/flavor.toml
Normal file
2
tests/modules/programs/yazi/flavor/flavor.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# This is a flavor.
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
-- This is a flavor.
|
|
0
tests/modules/programs/yazi/flavor/preview.png
Normal file
0
tests/modules/programs/yazi/flavor/preview.png
Normal file
0
tests/modules/programs/yazi/flavor/tmtheme.xml
Normal file
0
tests/modules/programs/yazi/flavor/tmtheme.xml
Normal file
|
@ -70,8 +70,22 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
initLua = ./init.lua;
|
initLua = ./init.lua;
|
||||||
plugins = { "test.yazi" = ./plugin; };
|
plugins = {
|
||||||
flavors = { "test.yazi" = ./flavor; };
|
testplugin = ./plugin;
|
||||||
|
## Produces warning
|
||||||
|
#"plugin-with-suffix.yazi" = ./plugin;
|
||||||
|
## Fails assertion
|
||||||
|
#single-file-plugin = ./plugin/init.lua;
|
||||||
|
#empty-dir-plugin = ./empty;
|
||||||
|
};
|
||||||
|
flavors = {
|
||||||
|
testflavor = ./flavor;
|
||||||
|
## Produces warning
|
||||||
|
#"flavor-with-suffix.yazi" = ./flavor;
|
||||||
|
## Fails assertion
|
||||||
|
#single-file-flavor = ./flavor/flavor.toml;
|
||||||
|
#empty-dir-flavor = ./empty;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
test.stubs.yazi = { };
|
test.stubs.yazi = { };
|
||||||
|
@ -85,9 +99,9 @@
|
||||||
${./theme-expected.toml}
|
${./theme-expected.toml}
|
||||||
assertFileContent home-files/.config/yazi/init.lua \
|
assertFileContent home-files/.config/yazi/init.lua \
|
||||||
${./init.lua}
|
${./init.lua}
|
||||||
assertFileContent home-files/.config/yazi/plugins/test.yazi/init.lua \
|
assertFileContent home-files/.config/yazi/plugins/testplugin.yazi/init.lua \
|
||||||
${./plugin/init.lua}
|
${./plugin/init.lua}
|
||||||
assertFileContent home-files/.config/yazi/flavors/test.yazi/init.lua \
|
assertFileContent home-files/.config/yazi/flavors/testflavor.yazi/flavor.toml \
|
||||||
${./flavor/init.lua}
|
${./flavor/flavor.toml}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue