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

mba6x_bl: init at 2016-02-12 #13688

Merged
merged 1 commit into from
Mar 7, 2016
Merged

mba6x_bl: init at 2016-02-12 #13688

merged 1 commit into from
Mar 7, 2016

Conversation

simonvandel
Copy link
Contributor

Things done:
  • Tested using sandboxing (nix-build --option build-use-chroot true or nix.useChroot on NixOS)
  • Built on platform(s): NixOS
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

This driver fixes backlight after suspend/resume on Macbook Air 6,1
and 6,2.

Added a workaround for patjak/mba6x_bl#43 in
form of a systemd service.

Has been working great on my machine for at least a month now.

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @edolstra, @bjornfor and @offlinehacker to be potential reviewers

@joachifm joachifm added 8.has: package (new) This PR adds a new package 8.has: module (new) This PR adds a module in `nixos/` labels Mar 5, 2016
services.mba6x_bl = {
enable = mkEnableOption "mba6x_bl";
};
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This will appear somewhat cryptic to readers of the man page, is it possible to provide a more descriptive name/docs?

@simonvandel
Copy link
Contributor Author

Oops, i screwed up. Let med restore this..

@simonvandel simonvandel reopened this Mar 5, 2016
@simonvandel
Copy link
Contributor Author

@joachifm : I changed the description based on your feedback.

@joachifm
Copy link
Contributor

joachifm commented Mar 5, 2016

Great. I'd like to get some feedback from others before merging this, though. Feel free to ping me if it ends up lingering for too long.

wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "/bin/sh -c \"${modprobe} -r mba6x_bl && ${modprobe} mba6x_bl\"";
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use script instead of calling sh yourself. It's documented over here: https://nixos.org/nixos/manual/options.html#opt-systemd.services._name_.script

@hrdinka
Copy link
Contributor

hrdinka commented Mar 6, 2016

Adding a whole module for a temporary workaround feels kinda wrong. Does this bug also occur when the module isn't auto loaded (by blacklisting it) but loaded manually or does it always need to be loaded twice to work?

@joachifm joachifm added the 9.needs: reporter feedback This issue needs the person who filed it to respond label Mar 6, 2016
@simonvandel
Copy link
Contributor Author

@hrdinka Thanks for your feedback. I will add fixes soon.

I don't know if it can be justified to make it a module. The driver can be loaded by users by setting boot.extraModulePackages = [ kernel.mba6x_bl ]; in their config file. I feel it is nicer for a module to do this. The workaround was easily added as a systemd unit to the module, making it work as expected without exposing this to the user.

@hrdinka
Copy link
Contributor

hrdinka commented Mar 6, 2016

Ok I see. So it's not only for the workaround. Then it might fit better as an extra option below programs.light (@puffnfresh) something like programs.light.mba6xSupport. @joachifm what's your opinion on that?

@simonvandel
Copy link
Contributor Author

It seems weird to relate the mba6x driver to the light utility. How do they relate other than being in the domain of background light?

@joachifm
Copy link
Contributor

joachifm commented Mar 6, 2016

Hm, what about the hardware. option namespace? Another possibility is to forgo the module and instead add a small snippet to the nixos-hardware repository. In the end I suppose we should do whatever makes the most sense for potential users; not being a user, I don't have much to contribute.

@hrdinka
Copy link
Contributor

hrdinka commented Mar 6, 2016

@joachifm that was my second idea. This option shouldn't be placed in services.

@simonvandel yes you are right. I fast fired. Technically it does not refer to the light program at all. I just like the idea of having it somewhere where it belongs instead of adding another top level option for a specific device that might be unnecessary in future. Something like:

hardware.backlight.enable # enable generic backlight control
hardware.backlight.macbookAir6xSupport # enables specific device drivers
hardware.backlight.samsungWhateverSupport # or workarounds
...

programs.light seemed natural to me because it is our only backlight control related option in nixos and might be the right backend for a more general backlight option.

@simonvandel
Copy link
Contributor Author

Hm, what about the hardware. option namespace?

This seems more appropriate.

@simonvandel
Copy link
Contributor Author

Something like:

hardware.backlight.enable # enable generic backlight control
hardware.backlight.macbookAir6xSupport # enables specific device drivers
hardware.backlight.samsungWhateverSupport # or workarounds

It would be nice to have a general framework for these kind of hardware specific packages. Another alternative is to leave the actual driver be in nixpkgs, but drop the module support. The use of the driver could then be documented in something like https://github.com/ehmry/nixos-hardware.

@hrdinka
Copy link
Contributor

hrdinka commented Mar 6, 2016

Or a more general hardware support and fixing scheme:

hardware.support.macbookAir6x # enables macbook air 6,x related drivers/fixs
hardware.support.dellXY
hardware.support.hpXY

@hrdinka
Copy link
Contributor

hrdinka commented Mar 6, 2016

@simonvandel thank's for the link, didn't know that. That's actually what my last propose would do under the hood.

@hrdinka
Copy link
Contributor

hrdinka commented Mar 6, 2016

My previous idea is a bad one. An entry for every device out there isn't practical and is absolutely impossible to maintain. I guess for your cause your last post shows the best solution. Just keep the package and add some documentation about its existence and the workaround. The bug itself is hopefully fixed soon upstream.

@joachifm
Copy link
Contributor

joachifm commented Mar 7, 2016

Suggestion: if the driver is useful on its own, submit a separate PR for it, then we can figure out how to best expose it to users later.

This driver fixes backlight after suspend/resume on Macbook Air 6,1
and 6,2.

Added a workaround for patjak/mba6x_bl#43 in
form of a systemd service.

Has been working great on my machine for at least a month now.
@simonvandel
Copy link
Contributor Author

I updated this PR to only include the packaging of the driver, and implemented the feedback received. Is this merge-able?

I will add some documentation to https://github.com/ehmry/nixos-hardware when I get the time.

@joachifm
Copy link
Contributor

joachifm commented Mar 7, 2016

It looks to be in keeping with similar packages already in the tree. If it's useful to you, it's sure to be useful to someone else. Thank you for your efforts.

joachifm added a commit that referenced this pull request Mar 7, 2016
@joachifm joachifm merged commit 375226f into NixOS:master Mar 7, 2016
@huacayacauh
Copy link

Hello,
May I ask how to use this package ? I have the exact problem it is supposed to fix (I am running nixos 15.09 on a macbook air 6.2), but can't manage to find out how to include it in my configuration...
Thank you for the work!

@joachifm
Copy link
Contributor

@huacayacauh did you try #13688 (comment)

@huacayacauh
Copy link

@joachifm thanks. Yes, in this case nixos-rebuild tells me that kernel variable is undefined. I don't know what I should substitute kernel for, my tries gave "attribute mba6x_bl missing".

@joachifm
Copy link
Contributor

I think you'd need to refer to boot.kernelPackages.mba6x_bl (untested)

@huacayacauh
Copy link

@joachifm
boot.kernelPackages.mba6x_bl gives undefined variable ‘boot’
config.boot.kernelPackages.mba6x_bl gives attribute ‘mba6x_bl’ missing

@joachifm
Copy link
Contributor

Oh, I see you're running 15.09; this is not available there.

@joachifm
Copy link
Contributor

It won't be in a release channel for a while. The earliest you'll get it is when the nixos-unstable channel becomes unstuck. Alternatively, you can clone NixOS/nixpkgs-channels at the release branch you want and cherry-pick the commit onto it. I won't go into details here, see the manual.

@huacayacauh
Copy link

@joachifm Ok, thank you very much for the quick answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: module (new) This PR adds a module in `nixos/` 8.has: package (new) This PR adds a new package 9.needs: reporter feedback This issue needs the person who filed it to respond
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants