-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
nixos/redshift: use config file instead of passing parameters, using RFC42 #108739
nixos/redshift: use config file instead of passing parameters, using RFC42 #108739
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Commit 73622d6 add tests so we can make sure this module works. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
/marvin opt-in |
Hi! I'm an experimental bot. My goal is to guide this PR through its stages, hopefully ending with a merge. You can read up on the usage here. |
${mainSection}.location-provider = lcfg.provider; | ||
manual = mkIf isManual { | ||
lat = mkIf options.location.latitude.isDefined lcfg.latitude; | ||
lon = mkIf options.location.longitude.isDefined lcfg.longitude; |
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.
Don't check for them being defined here, because we want an error if they're not defined.
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.
It is perfectly possible to use provider = manual
and set dawn-time
and dusk-time
instead (this is what I do). Otherwise we need a hack like setting latitude and longitude to 0 just to use dawn-time
and dusk-time
.
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.
Can location provider be set to null
🤔 ? If yes, I think I can remove those mkIf
s for latitude/longitude.
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.
Hum... Maybe checking if not dawn-time
and dusk-time
is set too would be better.
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.
Ah so by selecting manual
you have to either use lat
/lon
OR dawn-time
/dusk-time
? What happens if all four are set?
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.
What I am thinking is a check like this:
manual = mkIf isManual && !((cfg.settings ? ${mainSection}.dawn-time) && (cfg.settings ? ${mainSection}.dusk-time)) { ... }
It is quite big, but I think would work. WDYT @infinisil 🤔 ?
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.
Well, this doesn't work, infinite recursion.
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.
Ok, going to remove the mkIf
s. Can't think of a better solution and setting location = { latitude = 0.0; longitude = 0.0; }
does the trick.
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'll take a look at this again later, but this isn't a great solution at the moment. There's a mismatch between redshift's idea of "manual" and the location provider's idea of "manual". I think the location provider module might need some change.
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 also don't have a problem of having this merge as is and after those changes in location
is done I end up fixing this. Like, it is not ideal to have to set location to use time options but it works.
BTW, I think location
should support a location.provider = null
. This would work in this case because if provider isn't set we just use full manual mode.
Not every option is exposed by redshift/gammastep parameters, for example gamma options are only exposed in configuration file. So this PR refactors this module to generate a configuration file and pass it to the redshift/gammastep using -c parameter. This is a breaking change since there is no support for some of the older options like `extraConfig`. Also, the way to pass settings completely changed (but there is some aliases).
@infinisil Gave it a try in commit e59328b. It is kinda messy but I think it should look ok enough. |
(map (option: mkRenamedOptionModule ([ "services" "redshift" ] ++ option.old) [ "services" "redshift" "settings" "redshift" option.new ]) [ | ||
{ old = [ "temperature" "day" ]; new = "temp-day"; } | ||
{ old = [ "temperature" "night" ]; new = "temp-night"; } | ||
{ old = [ "brightness" "day" ]; new = "brightness-day"; } | ||
{ old = [ "brightness" "night" ]; new = "brightness-night"; } | ||
]); |
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.
Since we are already adding some options, maybe I could simply get those options back too with their old descriptions.
WDYT @infinisil ?
latitude = mkOption { | ||
type = types.nullOr types.float; | ||
default = null; | ||
example = "0.0"; |
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 don't know if this is a bug, but setting it as a float was making it not appear in manual.
…ptions This should make it more discoverable for the user what is the available options to needed to make the module work.
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
@infinisil Sorry to bother, but can you re-review this? I think this is now what you requested in comment #108739 (comment). |
I don't have a lot of time recently sorry. The redshift module unfortunately is rather complicated and some changes are still needed to make it work nicely. I made some initial ones here, but I'm out of brain power for today, I hope to have time for some clean module writing soon! |
@infinisil Good to know that this PR will be in good hands 😄 . I kinda of want of it merged ASAP, but since I use the release channels and there is still sometime until 21.05 it probably can wait. |
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
2 similar comments
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
I tested this with my configuration, looks good so far. |
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
3 similar comments
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
Reminder: Please review! This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually. |
I marked this as stale due to inactivity. → More info |
If there is someone interested in this PR I can rebase it to a newer release, however I will probably remove myself as maintainer since I don't use it anymore (I am using the equivalent from Home-Manager). |
Closing some old PRs of mine. |
Motivation for this change
Not every option is exposed by redshift/gammastep parameters, for example gamma options are only exposed in configuration file. So this PR refactors this module to generate a configuration file and pass it to the redshift/gammastep using -c parameter.
This is a breaking change since there is no support for some of the older options like
extraOptions
. Also, the way to pass settings completely changed (but there is some aliases).Second try of PR #108625, now following RFC 42. Also some parts of it taken from PR #50979.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)