mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
yazi: Fix expected structure of flavors
This commit is contained in:
parent
16f86c94ce
commit
216d51eb22
9 changed files with 75 additions and 13 deletions
|
@ -164,7 +164,7 @@ in {
|
||||||
default = { };
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
Pre-made themes.
|
Pre-made themes.
|
||||||
Values should be a package or path containing an `init.lua` file.
|
Values should be a package or path containing the required files.
|
||||||
Will be linked to {file}`$XDG_CONFIG_HOME/yazi/flavors/<name>.yazi`.
|
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.
|
||||||
|
@ -228,26 +228,37 @@ in {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assertions = let
|
assertions = let
|
||||||
mkAsserts = opt:
|
mkAsserts = opt: requiredFiles:
|
||||||
mapAttrsToList (name: value:
|
mapAttrsToList (name: value:
|
||||||
let
|
let
|
||||||
isDir = pathIsDirectory "${value}";
|
isDir = pathIsDirectory "${value}";
|
||||||
msgNotDir = optionalString (!isDir)
|
msgNotDir = optionalString (!isDir)
|
||||||
"The path or package should be a directory, not a single file.";
|
"The path or package should be a directory, not a single file.";
|
||||||
hasInitLua = pathExists "${value}/init.lua"
|
isFileMissing = file:
|
||||||
&& !(pathIsDirectory "${value}/init.lua");
|
!(pathExists "${value}/${file}")
|
||||||
msgNoInitLua = optionalString (!hasInitLua)
|
|| pathIsDirectory "${value}/${file}";
|
||||||
"The path or package must contain a file `init.lua`.";
|
missingFiles = filter isFileMissing requiredFiles;
|
||||||
|
msgFilesMissing = optionalString (missingFiles != [ ])
|
||||||
|
"The ${singularOpt} is missing these files: ${
|
||||||
|
toString missingFiles
|
||||||
|
}";
|
||||||
singularOpt = removeSuffix "s" opt;
|
singularOpt = removeSuffix "s" opt;
|
||||||
in {
|
in {
|
||||||
assertion = isDir && hasInitLua;
|
assertion = isDir && missingFiles == [ ];
|
||||||
message = ''
|
message = ''
|
||||||
Value at `programs.yazi.${opt}.${name}` is not a valid yazi ${singularOpt}.
|
Value at `programs.yazi.${opt}.${name}` is not a valid yazi ${singularOpt}.
|
||||||
${msgNotDir}
|
${msgNotDir}
|
||||||
${msgNoInitLua}
|
${msgFilesMissing}
|
||||||
Evaluated value: `${value}`
|
Evaluated value: `${value}`
|
||||||
'';
|
'';
|
||||||
}) cfg.${opt};
|
}) cfg.${opt};
|
||||||
in (mkAsserts "flavors") ++ (mkAsserts "plugins");
|
in (mkAsserts "flavors" [
|
||||||
|
"flavor.toml"
|
||||||
|
"tmtheme.xml"
|
||||||
|
"README.md"
|
||||||
|
"preview.png"
|
||||||
|
"LICENSE"
|
||||||
|
"LICENSE-tmtheme"
|
||||||
|
]) ++ (mkAsserts "plugins" [ "init.lua" ]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
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
|
@ -83,7 +83,7 @@
|
||||||
## Produces warning
|
## Produces warning
|
||||||
#"flavor-with-suffix.yazi" = ./flavor;
|
#"flavor-with-suffix.yazi" = ./flavor;
|
||||||
## Fails assertion
|
## Fails assertion
|
||||||
#single-file-flavor = ./flavor/init.lua;
|
#single-file-flavor = ./flavor/flavor.toml;
|
||||||
#empty-dir-flavor = ./empty;
|
#empty-dir-flavor = ./empty;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
${./init.lua}
|
${./init.lua}
|
||||||
assertFileContent home-files/.config/yazi/plugins/testplugin.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/testflavor.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