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/light: add control options #59742

Closed
wants to merge 1 commit into from
Closed

nixos/light: add control options #59742

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 16, 2019

Motivation for this change

As discussed in #57602 and #58609

cc @primeos @oxij in case you're interested

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nix-review --run "nix-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)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

${light} -O
'';

systemd.services.light = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be necessary, as systemd already handles this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

services.actkbd = mkIf cfg.mediaKeys.enable {
enable = true;
bindings = [
{ keys = [ 224 ]; events = [ "key" "rep" ]; command = "${light} -U ${toString cfg.mediaKeys.step}"; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we actually want to include these sorts of options in NixOS as they increase evaluation time for each user, and are not very complicated. I would prefer we add documentation to the wiki on how to do this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe this is better fit for NUR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grahamc What's the purpose of light module then? Also there is an inconsistency for laptop users. We have sound.mediaKeys but have no brightness keys control.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. The PR adding that also received the same feedback after it had been merged, and it wasn't removed to avoid breaking users who had already enabled it. The purpose is for setting up the udev rules and whatnot that the module already does.

@@ -4,6 +4,7 @@ with lib;

let
cfg = config.programs.light;
light = if cfg.devicePath != null then "${pkgs.light}/bin/light -s ${cfg.devicePath}" else "${pkgs.light}/bin/light";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do something like the following (untested):

light = "${pkgs.light}/bin/light" + optionalString (cfg.devicePath != null) " -s ${cfg.devicePath}";

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Synthetica9 Applied, thanks!

@oxij
Copy link
Member

oxij commented Apr 17, 2019 via email

@ghost
Copy link
Author

ghost commented Apr 17, 2019

@oxij

This has the advantage of not needing systemd, being configurable (instead of using some magic clamping), and setting brightness even before systemd starts, which seems like a nice addition to me.

Right. You can disable clamping with ENV{ID_BACKLIGHT_CLAMP}="0" in udev rules. But why to bother, if light is able to save and restore brightness level by itself?

Though, the problem in NixOS is that with systemd, systemd will override the backlight anyway, so I agree that either this piece of code does not belong to NixOS, or, alternatively, this should disable systemd-backlight when enabled.

I would disable systemd-backlight to avoid racing, just yet not found a way to do this.

@grahamc
Copy link
Member

grahamc commented Apr 17, 2019

Overall, these changes seem more suited for either documentation or NUR as @infinisil suggested.

@grahamc
Copy link
Member

grahamc commented Apr 17, 2019

The saving / restoring GC code doesn't belong, as systemd handles that for us.

The device path seem reasonable in the context of keybindings, but keybindings enshrined in the module also seems off-topic for NixOS's services.

Defining keybindings in the core of NixOS is essentially building a desktop environment in our services. Our services should be lighter and more generic. These settings should be in documentation, examples, or NUR.

@grahamc grahamc closed this Apr 17, 2019
@oxij
Copy link
Member

oxij commented Apr 17, 2019 via email

@ghost ghost deleted the light branch April 17, 2019 19:31
@ghost
Copy link
Author

ghost commented Apr 17, 2019

If you finish it, I'll take it (and if you don't, I'll take it and finish it myself later).

Please let me know what should I fix there.

@oxij
Copy link
Member

oxij commented Apr 18, 2019 via email

@oxij
Copy link
Member

oxij commented Apr 18, 2019 via email

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

5 participants