-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
vivid: add module #6045
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
Conversation
0f07e4f to
2b9f396
Compare
|
@folliehiyuki Hej, I just wanted to check if the PR is alright. It is my first in the |
modules/programs/vivid.nix
Outdated
| "set -gx LS_COLORS (${lib.getExe pkgs.vivid} generate ${theme})"; | ||
| nushellLine = theme: "${lib.getExe pkgs.vivid} generate ${theme}"; | ||
| zshLine = bashLine; | ||
| in { |
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 of lib afterward can be shorten.
modules/programs/vivid.nix
Outdated
| }; | ||
|
|
||
| theme = lib.mkOption { | ||
| type = lib.types.nullOr lib.types.str; |
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.
| type = lib.types.nullOr lib.types.str; | |
| type = with types; nullOr str; |
assuming that with lib; was declared above.
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.
The same goes for the other options as well.
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.
I have rewritten the module with with lib;.
I checked it multiple times, so there shouldn't be anything missing.
|
Can you also write a couple of assert tests for |
Do you have any examples on how to write those tests? I am not that experienced.
In Nix and put it in the |
295e83d to
04b689f
Compare
|
You can look into https://github.com/nix-community/home-manager/tree/master/tests/modules/programs for referenced assert test cases and how to write them.
I mean defining them in an assert test. You write the sample theme inside Nix and assert the generated theme file with expected value. |
6422963 to
2ea1b62
Compare
I looked into the new ghostty PR and took that init as a base to design the tests (plus some other modules as you suggested!). All of the tests pass on my device, I also went a bit overboard with the config, but I wanted to see if it works correctly! Hit me up if I need to reduce it :) I also fixed a small type in generating the |
|
@folliehiyuki sorry for the tag, but I wanted finish this PR so it can be integrated until the |
|
@rycee Hi, sorry for the ping, but I wanted to ask if someone could review the PR in march/april :) maybe you know someone, who has time on their hands, since Hoang seems to be busy. |
|
im not a reviewer, but my thoughts: this is a very simple program that generates static output based on the given theme name. and there is just a lot here to go over and maybe why there is a problem in getting a reviewer. the testing seems overkill. the test should be specific to the implementation of the nixos module working, not every aspect of the program itself -- that should be in upstream. I implement it like this: sessionVariables =
let
lsColors = builtins.readFile (
pkgs.runCommand "vivid-ls-colors" { } ''
${lib.getExe pkgs.vivid} generate dracula > $out
''
);
in
{
LS_COLORS = "${lsColors}";
}this allows nix build to run the vivid command to output LS_COLORS and stores it. it runs once on the build machine, not requiring the vivid binary to be copied to each host and to be run each time a login shell is executed. also this uses hope this helps |
|
@sedlund Thanks for the feedback! What would you recommend to focus the testing on? I am still new in that regard to nixos and home-manager. I just implemented the recommended changes using Just tried to do it at work and nuked my branch with a reset... But I should still have the files on my laptop at home! Afterwards I will reopen the PR or create a new one if I can't reopen this one! |
|
Reopening it |
be19dd8 to
96509d3
Compare
|
Sorry for the spam! As for the tests, I would refactor them if you have some suggestions or even an example. Should I just make the files smaller, like a minimal working example, and use that as a test? |
My thought is that the current test is only testing if I tested creating a small vivid generate mythemethis tests and verifies the and exits 1 This would be output now during build with your recent changes - and I think the output would be more useful. Nothing stands out to me what more could be tested. |
Not a reviewer either, but wouldn't this cause unnecessary import-from-derivation (IFD)? This would slow down evaluation and make the module unusable for people that have |
|
Interesting, was not aware. Although this happens currently here in a few spots already It could be stored as an argument and executed everytime a build is ran if it is of concern. It doesn't seem like this would be in critical code path though 🤷♀️ |
|
I guess this means I will revert it back to the shell options? I will also make a change to the testing suite, as proposed by @sedlund, triggering errors with faulty configs, instead of generating yaml configs. |
|
I really don't think IFD is an issue here at all. It is good to be aware of when doing it for large evals (package builds, etc). But in this context it only blocks eval when the vivid derivation or the config file changes. The eval takes 3ms on my machine. The time it would take to distribute the binary to various machines would take far longer. So doing this is still preferred computationally and network wise. I'd be happy to hear why this would not be true. |
|
deleted that suggestion, it was not correct |
|
Thank you for your contribution! I marked this pull request as stale due to inactivity. Please read the relevant sections below before commenting. If you are the original author of the PR
If you are not the original author of the PR
|
|
Vivid support was added here #7772 |
Thanks for the update! I will close this PR now :) |
|
FYI I took no part in #7772, I just noticed that it was merged and decided to notify you :) |
Description
Add module for https://github.com/sharkdp/vivid.
Previous PRs #2194 and #3705 addressed this, but never merged.
The
themesandfiletypessection were taken from #2194.The shell integrations are used since the variable name
LS_COLORSneeds to be set to the output of the commandvivid generate <theme>. One could utilize what #2194 used:but this wouldn't work for
fishandnushell.Checklist
Change is backwards compatible.
Code formatted with
./format.Code tested through
nix-shell --pure tests -A run.allornix develop --ignore-environment .#allusing Flakes.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
Maintainer CC