-
Notifications
You must be signed in to change notification settings - Fork 108
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
Check if options exist before setting them #226
Conversation
lib/devos/mkHosts.nix
Outdated
|
||
system.configurationRevision = lib.mkIf (self ? rev) self.rev; | ||
} | ||
(lib.optionalAttrs (options ? home-manager) { |
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.
This can't just be // optionalAttrs ...
, that causes an infinite recursion error.
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.
got mkMerge
strategy from https://discourse.nixos.org/t/how-to-check-is-an-option-available/2919/2
Does process on gytis-ivaskevicius/flake-utils-plus#18 feed any information back on this? |
I actually did that PR with knowledge I gained from working on this. |
Just realized, once we implement config generators in a |
I think the code in mkHosts, is relevant, where we set the home-manager defaults if the option exists. And there are a couple other things, that are useful, for example deploy might not be in the users packages, so we don't want to add it to shell, unless it exists. |
Is this still an issue/needed? |
We should put it on-hold until we have devos lib and clarity of which dependency can be expected where, we might else get dead code out of this while refactoring. |
Yeah most of this is unnecessary with the move to pkgs-lib. I think we have now forced lib to depend on deploy-rs. |
480e024
to
790538b
Compare
planning to rework mkHosts, so I might include these changes in that PR. But we'll see where it goes. |
mkHosts is not very portable since it relies on nixos options. Which means in the future it can't be used on nix-darwin or robotnix. So here I just wrapped every option thats set to first check if it exists.
I would also like to set the precedent for future integrations added into devos to be made optional with similar methods:
pkgs ? deploy-rs
options ? home-manager
. This one is tricky, it can't be done withmkIf
. You have to use a combination ofmkMerge
andoptionalAttrs
, the former is usually necessary when your setting other things and the same module and you want to set an option that might not exist. See changes in devosSystem and mkHosts for examples.inputs ? deploy
self ? homeConfigurations
. Not sure what to do about this one though, most tests are tightly integrated with devos.