-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vivid: add module #6045
Open
arunoruto
wants to merge
1
commit into
nix-community:master
Choose a base branch
from
arunoruto:vivid
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+142
−0
Open
vivid: add module #6045
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,141 @@ | ||||||
{ config, lib, pkgs, ... }: | ||||||
let | ||||||
yaml = pkgs.formats.yaml { }; | ||||||
bashLine = theme: | ||||||
''export LS_COLORS="$(${lib.getExe pkgs.vivid} generate ${theme})"''; | ||||||
fishLine = theme: | ||||||
"set -gx LS_COLORS (${lib.getExe pkgs.vivid} generate ${theme})"; | ||||||
nushellLine = theme: "${lib.getExe pkgs.vivid} generate ${theme}"; | ||||||
zshLine = bashLine; | ||||||
in { | ||||||
meta.maintainers = [ lib.maintainers.arunoruto ]; | ||||||
|
||||||
options.programs.vivid = { | ||||||
enable = lib.mkEnableOption '' | ||||||
vivid - A themeable LS_COLORS generator with a rich filetype datebase | ||||||
<link xlink:href="https://github.com/sharkdp/vivid" /> | ||||||
''; | ||||||
|
||||||
package = lib.mkPackageOption pkgs "vivid" { }; | ||||||
|
||||||
enableBashIntegration = lib.mkOption { | ||||||
default = true; | ||||||
type = lib.types.bool; | ||||||
description = '' | ||||||
Whether to enable Bash integration. | ||||||
Adds `${bashLine "<theme>"}` to Bash. | ||||||
''; | ||||||
}; | ||||||
|
||||||
enableFishIntegration = lib.mkOption { | ||||||
default = true; | ||||||
type = lib.types.bool; | ||||||
description = '' | ||||||
Whether to enable Fish integration. | ||||||
Adds `${fishLine "<theme>"}` to Fish. | ||||||
''; | ||||||
}; | ||||||
|
||||||
enableNushellIntegration = lib.mkOption { | ||||||
default = true; | ||||||
type = lib.types.bool; | ||||||
description = '' | ||||||
Whether to enable Nushell integration. | ||||||
Adds `${nushellLine "<theme>"}` to Nushell. | ||||||
''; | ||||||
}; | ||||||
|
||||||
enableZshIntegration = lib.mkOption { | ||||||
default = true; | ||||||
type = lib.types.bool; | ||||||
description = '' | ||||||
Whether to enable Zsh integration. | ||||||
Adds `${zshLine "<theme>"}` to Zsh. | ||||||
''; | ||||||
}; | ||||||
|
||||||
theme = lib.mkOption { | ||||||
type = lib.types.nullOr lib.types.str; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
assuming that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same goes for the other options as well. |
||||||
default = null; | ||||||
example = "molokai"; | ||||||
description = '' | ||||||
Color theme to enable. | ||||||
Run `vivid themes` for a list of available themes. | ||||||
''; | ||||||
}; | ||||||
|
||||||
filetypes = lib.mkOption { | ||||||
type = yaml.type; | ||||||
default = { }; | ||||||
example = lib.literalExample '' | ||||||
{ | ||||||
core = { | ||||||
regular_file = [ "$fi" ]; | ||||||
directory = [ "$di" ]; | ||||||
}; | ||||||
text = { | ||||||
readme = [ "README.md" ]; | ||||||
licenses = [ "LICENSE" ]; | ||||||
}; | ||||||
} | ||||||
''; | ||||||
description = '' | ||||||
Configuration written to | ||||||
<filename>~/.config/vivid/filetypes.yml</filename>. | ||||||
Visit <link xlink:href="https://github.com/sharkdp/vivid/tree/master/config/filetypes.yml" /> | ||||||
for a reference file. | ||||||
''; | ||||||
}; | ||||||
|
||||||
themes = lib.mkOption { | ||||||
type = lib.types.attrsOf (yaml.type); | ||||||
default = { }; | ||||||
example = lib.literalExample '' | ||||||
{ | ||||||
mytheme = { | ||||||
colors = { | ||||||
blue = "0000ff"; | ||||||
}; | ||||||
core = { | ||||||
directory = { | ||||||
foreground = "blue"; | ||||||
font-style = "bold"; | ||||||
}; | ||||||
}; | ||||||
}; | ||||||
} | ||||||
''; | ||||||
description = '' | ||||||
Theme files written to | ||||||
<filename>~/.config/vivid/themes/<mytheme>.yml</filename>. | ||||||
Visit <link xlink:href="https://github.com/sharkdp/vivid/tree/master/themes" /> | ||||||
for references. | ||||||
''; | ||||||
}; | ||||||
}; | ||||||
|
||||||
config = let cfg = config.programs.vivid; | ||||||
in lib.mkIf cfg.enable { | ||||||
home.packages = [ cfg.package ]; | ||||||
|
||||||
programs.bash.initExtra = | ||||||
lib.mkIf cfg.enableBashIntegration (bashLine cfg.theme); | ||||||
programs.fish.interactiveShellInit = | ||||||
lib.mkIf cfg.enableFishIntegration (fishLine cfg.theme); | ||||||
programs.nushell.environmentVariables.LS_COLORS = | ||||||
lib.mkIf cfg.enableNushellIntegration | ||||||
(lib.hm.nushell.mkNushellInline (nushellLine cfg.theme)); | ||||||
programs.zsh.initExtra = | ||||||
lib.mkIf cfg.enableZshIntegration (zshLine cfg.theme); | ||||||
|
||||||
xdg.configFile = { | ||||||
"vivid/filetypes.yml" = | ||||||
lib.mkIf (builtins.length (builtins.attrNames cfg.filetypes) > 0) { | ||||||
source = yaml.generate "filetypes.yml" cfg.filetypes; | ||||||
}; | ||||||
} // lib.mapAttrs' (name: value: | ||||||
lib.nameValuePair "vivid/themes/${name}.yml" { | ||||||
source = yaml.generate "${name}.yml" value; | ||||||
}) cfg.themes; | ||||||
}; | ||||||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can put a
with lib;
declaration here, so usages oflib
afterward can be shorten.