Skip to content
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

Closed
wants to merge 4 commits into from
Closed

nixos/redshift: use config file instead of passing parameters, using RFC42 #108739

wants to merge 4 commits into from

Conversation

thiagokokada
Copy link
Contributor

@thiagokokada thiagokokada commented Jan 8, 2021

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
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@thiagokokada

This comment has been minimized.

@thiagokokada

This comment has been minimized.

nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Show resolved Hide resolved
@thiagokokada

This comment has been minimized.

@thiagokokada

This comment has been minimized.

@thiagokokada
Copy link
Contributor Author

thiagokokada commented Jan 8, 2021

Commit 73622d6 add tests so we can make sure this module works.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/437

@thiagokokada

This comment has been minimized.

@thiagokokada

This comment has been minimized.

@thiagokokada
Copy link
Contributor Author

/marvin opt-in
/status needs_reviewer

@marvin-mk2 marvin-mk2 bot added the marvin label Jan 11, 2021
@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 11, 2021

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.

nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
nixos/modules/services/x11/redshift.nix Outdated Show resolved Hide resolved
${mainSection}.location-provider = lcfg.provider;
manual = mkIf isManual {
lat = mkIf options.location.latitude.isDefined lcfg.latitude;
lon = mkIf options.location.longitude.isDefined lcfg.longitude;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 mkIfs for latitude/longitude.

Copy link
Contributor Author

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.

Copy link
Member

@infinisil infinisil Jan 12, 2021

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?

Copy link
Contributor Author

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 🤔 ?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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 mkIfs. Can't think of a better solution and setting location = { latitude = 0.0; longitude = 0.0; } does the trick.

Copy link
Member

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.

Copy link
Contributor Author

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.

pkgs/applications/misc/redshift/default.nix Show resolved Hide resolved
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).
@thiagokokada
Copy link
Contributor Author

thiagokokada commented Jan 15, 2021

@infinisil Gave it a try in commit e59328b. It is kinda messy but I think it should look ok enough.

Comment on lines +19 to +24
(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"; }
]);
Copy link
Contributor Author

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";
Copy link
Contributor Author

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.
@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 18, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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.

@thiagokokada
Copy link
Contributor Author

@infinisil Sorry to bother, but can you re-review this? I think this is now what you requested in comment #108739 (comment).

@infinisil
Copy link
Member

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!

@thiagokokada
Copy link
Contributor Author

@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.

@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 25, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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.

@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 28, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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
@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 31, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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.

@marvin-mk2
Copy link

marvin-mk2 bot commented Feb 3, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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.

@xaverdh
Copy link
Contributor

xaverdh commented Feb 3, 2021

I tested this with my configuration, looks good so far.

@marvin-mk2
Copy link

marvin-mk2 bot commented Feb 6, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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
@marvin-mk2
Copy link

marvin-mk2 bot commented Feb 9, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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.

@marvin-mk2
Copy link

marvin-mk2 bot commented Feb 12, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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.

@marvin-mk2
Copy link

marvin-mk2 bot commented Feb 15, 2021

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 will be should be put back in the needs_reviewer queue in one day.


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.

@stale
Copy link

stale bot commented Aug 21, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 21, 2021
@thiagokokada
Copy link
Contributor Author

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).

@thiagokokada
Copy link
Contributor Author

Closing some old PRs of mine.

@thiagokokada thiagokokada deleted the redshift-module-refactor-rfc42 branch January 11, 2022 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants