mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
vivid: add module (#7772)
This commit is contained in:
parent
6159629d05
commit
b21c1a61a7
7 changed files with 458 additions and 0 deletions
11
modules/misc/news/2025/09/2025-09-03_18-44-34.nix
Normal file
11
modules/misc/news/2025/09/2025-09-03_18-44-34.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
time = "2025-09-03T21:44:34+00:00";
|
||||
condition = true;
|
||||
message = ''
|
||||
A new module is available: `programs.vivid`
|
||||
|
||||
Vivid is a generator for the LS_COLORS environment variable
|
||||
that controls the colorized output of ls, tree, fd, bfs, dust
|
||||
and many other tools.
|
||||
'';
|
||||
}
|
||||
134
modules/programs/vivid.nix
Normal file
134
modules/programs/vivid.nix
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
mkIf
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
types
|
||||
;
|
||||
|
||||
inherit (lib.hm.shell)
|
||||
mkBashIntegrationOption
|
||||
mkZshIntegrationOption
|
||||
mkFishIntegrationOption
|
||||
;
|
||||
|
||||
cfg = config.programs.vivid;
|
||||
yamlFormat = pkgs.formats.yaml { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||
|
||||
options.programs.vivid = {
|
||||
enable = mkEnableOption "vivid";
|
||||
package = mkPackageOption pkgs "vivid" { nullable = true; };
|
||||
|
||||
enableBashIntegration = mkBashIntegrationOption { inherit config; };
|
||||
enableZshIntegration = mkZshIntegrationOption { inherit config; };
|
||||
enableFishIntegration = mkFishIntegrationOption { inherit config; };
|
||||
|
||||
colorMode = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
example = "8-bit";
|
||||
description = ''
|
||||
Color mode for vivid.
|
||||
'';
|
||||
};
|
||||
|
||||
filetypes = mkOption {
|
||||
inherit (yamlFormat) type;
|
||||
default = { };
|
||||
example = {
|
||||
text = {
|
||||
special = [
|
||||
"CHANGELOG.md"
|
||||
"CODE_OF_CONDUCT.md"
|
||||
"CONTRIBUTING.md"
|
||||
];
|
||||
|
||||
todo = [
|
||||
"TODO.md"
|
||||
"TODO.txt"
|
||||
];
|
||||
|
||||
licenses = [
|
||||
"LICENCE"
|
||||
"COPYRIGHT"
|
||||
];
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
Filetype database for vivid. You can find an example config at:
|
||||
<https://github.com/sharkdp/vivid/blob/master/config/filetypes.yml>.
|
||||
'';
|
||||
};
|
||||
|
||||
activeTheme = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
example = "molokai";
|
||||
description = ''
|
||||
Active theme for vivid.
|
||||
'';
|
||||
};
|
||||
|
||||
themes = mkOption {
|
||||
type = with types; attrsOf path;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
ayu = builtins.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/NearlyTRex/Vivid/refs/heads/master/themes/ayu.yml";
|
||||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
};
|
||||
|
||||
mocha = builtins.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/NearlyTRex/Vivid/refs/heads/master/themes/catppuccin-mocha.yml";
|
||||
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = "Theme for vivid";
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
vividCommand = "vivid ${
|
||||
lib.optionalString (cfg.colorMode != null) "-m ${cfg.colorMode}"
|
||||
} generate ${lib.optionalString (cfg.activeTheme != null) cfg.activeTheme}";
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
home.sessionVariables = mkIf (cfg.activeTheme != null) { VIVID_THEME = cfg.activeTheme; };
|
||||
|
||||
xdg.configFile = {
|
||||
"vivid/filetypes.yml" = mkIf (cfg.filetypes != { }) {
|
||||
source = yamlFormat.generate "vivid-filetypes" cfg.filetypes;
|
||||
};
|
||||
}
|
||||
// (lib.mapAttrs' (
|
||||
name: path: lib.nameValuePair "vivid/themes/${name}.yml" { source = path; }
|
||||
) cfg.themes);
|
||||
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
||||
export LS_COLORS="$(${vividCommand})"
|
||||
'';
|
||||
|
||||
programs.zsh.initContent = mkIf cfg.enableZshIntegration ''
|
||||
export LS_COLORS="$(${vividCommand})"
|
||||
'';
|
||||
|
||||
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
||||
set -gx LS_COLORS "$(${vividCommand})"
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue