-
Notifications
You must be signed in to change notification settings - Fork 2
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: add feature flags to module configuration #16
base: master
Are you sure you want to change the base?
Conversation
A bit confusing. Do you have a real example of using this feature? Also, a note for the documentation: options = { featured, ... }: delib.featuresEnableOption featured [ "c1_foo" ] { name = "child1"; }; (the more preferred option) options = { featured, ... } @ args: delib.featuresEnableOption featured [ "c1_foo" ] args; |
I want to have a little more than just an enable option, but without writing custom options. It's possible to create nested features by passing down the featured variable, but I think one-level deep feature flags alongside the enable option should cover most cases while keeping the ability to set part of the module as active. I like how I solved one-level structures; nested structures are a bit uglier because I didn't want to combine feature flags name with module name to create another option level. I also didn't want to add another option function because I thought it would bloat the options. Correct me if you think otherwise.
Here's real world example of refactored audio module Idea here is like: While I could mix |
Tomorrow I'll take a closer look at this, but for now, check out my Neovim configuration here: https://github.com/yunfachi/nix-config/blob/master/modules/programs/nixvim/default.nix. Each plugin is a separate module with its own options, like this one: https://github.com/yunfachi/nix-config/blob/master/modules/programs/nixvim/plugins/which-key.nix. Is this similar to your issue? |
Yup, and you're controlling modules through the enabled flag. With my approach you could modularize your nvim config even further: nixvim/default.nix
plugins/which-key.nix
This way which-key plugin will be conditionally included based on featuresEnableOption defaults, but you can still override the features list in your host or rice directories if needed. |
This really looks good for some cases, but it has a few drawbacks:
To avoid making the library more complex, I suggest creating a directory for addons after completing #5 and adding this there. It would look something like this: delib.configurations {
# ...
libExtensions = [
./myCustomLib
delib.addons.featureFlags
];
} What do you think? |
This way is the way to go, you proposed a way better solution than integrating feature flags into the project core. I will think on how extending the lib could be solved at the end of the week if you don't tackle this issue beforehand. It would be a great exercise for improving my Nix skills :) |
Thanks for understanding! What do you think about optionally adding an enum to this option? For example, |
No worries! I discovered your library by accident, and really like it as it made my modules so beautiful! 🥇 Regarding naming conventions, I would suggest not prefixing the feature name with a specific type. Instead, I prefer using singular words rather than words that indicate multiple options. When developing ui components, I frequently work with properties like |
Adds an
ifFeatured
option to provide granular control over module behavior without requiring full custom configuration. This sits alongside the existing enable flag, allowing for more flexible module control while maintaining simplicity.Example configuration can be found here
This results in proper feature flag evaluation, as shown in the trace output:
What do you think about this change?