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

Conversation

trueNAHO
Copy link
Collaborator

About

Closes: #153

Need Help

Currently, this PR does not integrate with NixVim's generated configuration file. This might be related to NixVim not being a Home Manager module.

Copy link
Owner

@danth danth left a comment

Choose a reason for hiding this comment

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

programs.nixvim is not available by default so this will cause an error for configs without NixVim imported.

Also, the module file needs to be called hm.nix, nixos.nix or darwin.nix to be loaded properly. It looks like NixVim can be installed on any of those, so we should support them all. If the modules are identical then each file can just import ./nixvim.nix, or symlinks might work instead.

modules/nixvim/nixvim.nix Outdated Show resolved Hide resolved
@trueNAHO trueNAHO marked this pull request as draft October 23, 2023 20:35
@trueNAHO
Copy link
Collaborator Author

programs.nixvim is not available by default so this will cause an error for configs without NixVim imported.

Should I add NixVim to the flake.nix inputs?

@danth
Copy link
Owner

danth commented Oct 28, 2023

That would cause it to be installed for a lot of people who don't want to use it.

@trueNAHO
Copy link
Collaborator Author

That would cause it to be installed for a lot of people who don't want to use it.

Do you have any other proposals?

Conditionally calling fetchFromGithub would not be ideal as we lose major benefits that Flakes provide. Hence, we either add NixVim to the Flake inputs, or we do not add it as an input at all. In the latter case, we should assert NixVim being available in the scope that uses Stylix as input.

Do you have any ideas on how to check if NixVim is available?

@danth
Copy link
Owner

danth commented Oct 28, 2023

This was something we discussed back when the Hyprland module was not part of Home Manager. In short we came to the decision not to add anything to Stylix which relies on an external module being imported, which NixVim does.

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.)

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.

@trueNAHO
Copy link
Collaborator Author

trueNAHO commented Nov 2, 2023

Also, the module file needs to be called hm.nix, nixos.nix or darwin.nix to be loaded properly. It looks like NixVim can be installed on any of those, so we should support them all. If the modules are identical then each file can just import ./nixvim.nix, or symlinks might work instead.

I will work on this once I have more free time.

@willemml
Copy link
Contributor

willemml commented Nov 25, 2023

I have fixed the issues with this PR in this fork: https://github.com/willemml/stylix/tree/feat/modules/nixvim
See commit willemml@8bb621e.

I have tested that the build succeeds without installing nixvim. Colors are applied correctly. The only thing I cannot figure out is transparency, the base nixvim theme follows my terminal's transparency settings while this stylix module sets the background to a solid colour. (See edit.)

Assuming these fixes/changes are acceptable should I submit this as a separate PR to the main danth/stylix repo?

EDIT: I have added an option for terminal transparency passthrough in a separate branch, I am unsure if this follows stylix module guidelines but here it is: https://github.com/willemml/stylix/tree/feat/modules/nixvim-transparency (willemml@12108f4).

@trueNAHO
Copy link
Collaborator Author

trueNAHO commented Nov 30, 2023

I have tested that the build succeeds without installing nixvim. Colors are applied correctly.

I have not tested your PR, but the code looks good.

I have added an option for terminal transparency passthrough in a separate branch, I am unsure if this follows stylix module guidelines but here it is: https://github.com/willemml/stylix/tree/feat/modules/nixvim-transparency (willemml@12108f4).

I don't see how more options would be problematic. @danth, what do you think?

Assuming these fixes/changes are acceptable should I submit this as a separate PR to the main danth/stylix repo?

Regardless of transparency being accepted, your PR already supersedes mine. Feel free to open a new PR to your https://github.com/willemml/stylix/tree/feat/modules/nixvim-transparency branch, and link it to the original issue and this PR. This makes it easier to close this PR and the original issue later on.

@trueNAHO
Copy link
Collaborator Author

trueNAHO commented Dec 3, 2023

Superseded by #194.

@trueNAHO trueNAHO closed this Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add NixVim support
3 participants