programs.zsh.syntax-highlighting: refactor highlighters
option for proper validation
#25210
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.
Motivation for this change
Today after updating my nix-channel (which included the changes from #25153) I updated my personal NixOS setup to configure the
zsh-syntax-highlighting
properly, but I mistyped one of thehighlighters
which caused my shell to do odd things.At first I feared that I broke NixOS, but in the end I've seen that it was just a stupid typo. However this showed me that it might be a good idea to replace the
types.list(types.str)
declaration ofprograms.zsh.syntax-highlighting.highlighters
with atypes.list(types.enum([/* available highlighters */]))
to ensure stricter validation.Although the validation is restricted here this is IMHO not a BC break due to the fact that everything will continue to work if no invalid highlighters were given (but if that happened the shell would be almost unusable).
I validated the patch by using two configurations that were deployed in a test VM:
I booted the VMs using the following command:
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)