mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-09 02:06:53 +00:00
yazi: remove with lib
This commit is contained in:
parent
c0d06189f2
commit
b34b56689d
1 changed files with 24 additions and 21 deletions
|
@ -1,8 +1,10 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (lib)
|
||||||
|
literalExpression mapAttrsToList mkEnableOption mkIf mkOption optionalString
|
||||||
|
types;
|
||||||
|
|
||||||
cfg = config.programs.yazi;
|
cfg = config.programs.yazi;
|
||||||
tomlFormat = pkgs.formats.toml { };
|
tomlFormat = pkgs.formats.toml { };
|
||||||
|
|
||||||
|
@ -43,9 +45,9 @@ in {
|
||||||
options.programs.yazi = {
|
options.programs.yazi = {
|
||||||
enable = mkEnableOption "yazi";
|
enable = mkEnableOption "yazi";
|
||||||
|
|
||||||
package = mkPackageOption pkgs "yazi" { };
|
package = lib.mkPackageOption pkgs "yazi" { };
|
||||||
|
|
||||||
shellWrapperName = mkOption {
|
shellWrapperName = lib.mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "yy";
|
default = "yy";
|
||||||
example = "y";
|
example = "y";
|
||||||
|
@ -218,27 +220,27 @@ in {
|
||||||
} else {
|
} else {
|
||||||
text = cfg.initLua;
|
text = cfg.initLua;
|
||||||
});
|
});
|
||||||
} // (mapAttrs' (name: value:
|
} // (lib.mapAttrs' (name: value:
|
||||||
nameValuePair "yazi/flavors/${name}.yazi" { source = value; })
|
lib.nameValuePair "yazi/flavors/${name}.yazi" { source = value; })
|
||||||
cfg.flavors) // (mapAttrs' (name: value:
|
cfg.flavors) // (lib.mapAttrs' (name: value:
|
||||||
nameValuePair "yazi/plugins/${name}.yazi" { source = value; })
|
lib.nameValuePair "yazi/plugins/${name}.yazi" { source = value; })
|
||||||
cfg.plugins);
|
cfg.plugins);
|
||||||
|
|
||||||
warnings = filter (s: s != "") (concatLists [
|
warnings = lib.filter (s: s != "") (lib.concatLists [
|
||||||
(mapAttrsToList (name: value:
|
(mapAttrsToList (name: _value:
|
||||||
optionalString (hasSuffix ".yazi" name) ''
|
optionalString (lib.hasSuffix ".yazi" name) ''
|
||||||
Flavors like `programs.yazi.flavors."${name}"` should no longer have the suffix ".yazi" in their attribute 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`.
|
The flavor will be linked to `$XDG_CONFIG_HOME/yazi/flavors/${name}.yazi`.
|
||||||
You probably want to rename it to `programs.yazi.flavors."${
|
You probably want to rename it to `programs.yazi.flavors."${
|
||||||
removeSuffix ".yazi" name
|
lib.removeSuffix ".yazi" name
|
||||||
}"`.
|
}"`.
|
||||||
'') cfg.flavors)
|
'') cfg.flavors)
|
||||||
(mapAttrsToList (name: value:
|
(mapAttrsToList (name: _value:
|
||||||
optionalString (hasSuffix ".yazi" name) ''
|
optionalString (lib.hasSuffix ".yazi" name) ''
|
||||||
Plugins like `programs.yazi.plugins."${name}"` should no longer have the suffix ".yazi" in their attribute 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`.
|
The plugin will be linked to `$XDG_CONFIG_HOME/yazi/plugins/${name}.yazi`.
|
||||||
You probably want to rename it to `programs.yazi.plugins."${
|
You probably want to rename it to `programs.yazi.plugins."${
|
||||||
removeSuffix ".yazi" name
|
lib.removeSuffix ".yazi" name
|
||||||
}"`.
|
}"`.
|
||||||
'') cfg.plugins)
|
'') cfg.plugins)
|
||||||
]);
|
]);
|
||||||
|
@ -247,20 +249,21 @@ in {
|
||||||
mkAsserts = opt: requiredFiles:
|
mkAsserts = opt: requiredFiles:
|
||||||
mapAttrsToList (name: value:
|
mapAttrsToList (name: value:
|
||||||
let
|
let
|
||||||
isDir = pathIsDirectory "${value}";
|
isDir = lib.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.";
|
||||||
isFileMissing = file:
|
isFileMissing = file:
|
||||||
!(pathExists "${value}/${file}")
|
!(lib.pathExists "${value}/${file}")
|
||||||
|| pathIsDirectory "${value}/${file}";
|
|| lib.pathIsDirectory "${value}/${file}";
|
||||||
missingFiles = filter isFileMissing requiredFiles;
|
missingFiles = lib.filter isFileMissing requiredFiles;
|
||||||
msgFilesMissing = optionalString (missingFiles != [ ])
|
msgFilesMissing = optionalString (missingFiles != [ ])
|
||||||
"The ${singularOpt} is missing these files: ${
|
"The ${singularOpt} is missing these files: ${
|
||||||
toString missingFiles
|
toString missingFiles
|
||||||
}";
|
}";
|
||||||
singularOpt = removeSuffix "s" opt;
|
singularOpt = lib.removeSuffix "s" opt;
|
||||||
isPluginValid = opt == "plugins"
|
isPluginValid = opt == "plugins"
|
||||||
&& (any (file: pathExists "${value}/${file}") requiredFiles);
|
&& (lib.any (file: lib.pathExists "${value}/${file}")
|
||||||
|
requiredFiles);
|
||||||
isValid =
|
isValid =
|
||||||
if opt == "plugins" then isPluginValid else missingFiles == [ ];
|
if opt == "plugins" then isPluginValid else missingFiles == [ ];
|
||||||
in {
|
in {
|
||||||
|
|
Loading…
Add table
Reference in a new issue