Skip to content
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

feat(modules/nixvim): add color scheme #178

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions modules/nixvim/nixvim.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
config,
lib,
...
}: {
options.stylix.targets.nixvim.enable =
config.lib.stylix.mkEnableTarget "nixvim" true;

config = lib.mkIf config.stylix.targets.nixvim.enable {
Copy link
Collaborator Author

@trueNAHO trueNAHO Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to experiment anyway, options.programs?nixvim would return true when programs.nixvim exists as an option. (options can be loaded at the top of the file similar to pkgs and config.)

(Source: #178 (comment))

What about the following assertion:

Suggested change
config = lib.mkIf config.stylix.targets.nixvim.enable {
config = lib.mkIf config.stylix.targets.nixvim.enable {
assertions = [
{
assertion = options.programs?nixvim;
message = ''
'stylix.targets.nixvim.enable' is set to
${config.stylix.targets.nixvim.enable}, but the external
'options.programs.nixvim' dependency is unavailable:
https://github.com/nix-community/nixvim
'';
}
];

Note that I have not actually tested this.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With mkIf, evaluation still fails when the option doesn't exist, even if config.stylix.targets.nixvim.enable is set to false

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following should gracefully skip evaluation if config.stylix.targets.nixvim is not available:

Suggested change
config = lib.mkIf config.stylix.targets.nixvim.enable {
config = let
targets = config.stylix.targets;
in lib.mkIf (targets?nixvim.enable && targets.nixivm.enable) {

Note that I have not actually tested this.

programs.nixvim.colorschemes.base16.customColorScheme = let
colors = config.lib.stylix.colors;
prependHash = color: "#${color}";
in {
base00 = prependHash colors.base00;
base01 = prependHash colors.base01;
base02 = prependHash colors.base02;
base03 = prependHash colors.base03;
base04 = prependHash colors.base04;
base05 = prependHash colors.base05;
base06 = prependHash colors.base06;
base07 = prependHash colors.base07;
base08 = prependHash colors.base08;
base09 = prependHash colors.base09;
base0A = prependHash colors.base0A;
base0B = prependHash colors.base0B;
base0C = prependHash colors.base0C;
base0D = prependHash colors.base0D;
base0E = prependHash colors.base0E;
base0F = prependHash colors.base0F;
trueNAHO marked this conversation as resolved.
Show resolved Hide resolved
};
};
}