Navigation Menu

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

brillo: init at 1.4.8 #58173

Merged
merged 1 commit into from Nov 3, 2019
Merged

brillo: init at 1.4.8 #58173

merged 1 commit into from Nov 3, 2019

Conversation

alexarice
Copy link
Contributor

Motivation for this change

I wanted to use the brillo tool for backlight control on wayland but i could not find it.

Things done

Added brillo to nixpkgs/pkgs/os-specific/linux/brillo and added myself as a maintainer of it.

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

I have not tried to add a nix package before so please let me know if I have messed something up.

@alexarice
Copy link
Contributor Author

Have just realised this is not putting the udev rule in the correct location. Will try to fix soon

url = "https://gitlab.com/cameronnemo/brillo/-/archive/v${v}/brillo-v${v}.tar.bz2";
sha256 = "0wjpw9vn521rwpnlhvczzfzdsdq812vsyl151627qw51zadynvz1";
};
patches = [./brillo.patch];
Copy link
Member

Choose a reason for hiding this comment

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

Can you briefly explain the rationale for the patch either in the patch header or in a comment here?
Installing apparmor rules seems harmless to me; NixOS even has (some) apparmor support.

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've just made another commit which changes all this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I add something along the lines of security.apparmor.packages = [pkgs.brillo] ?

pkgs/os-specific/linux/brillo/default.nix Outdated Show resolved Hide resolved
pkgs/os-specific/linux/brillo/default.nix Outdated Show resolved Hide resolved
pkgs/os-specific/linux/brillo/default.nix Outdated Show resolved Hide resolved
};


config = mkIf cfg.enable {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might also need environment.systemPackages for polkit rules.

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 have done this and now pkexec works but only if you input the full path (e.g. pkexec /nix/store/ddavxh7mmbmxds6wpvqws1jw34j3nldh-brillo-1.4.3/bin/brillo -A 5) I don't know if this is how it should be

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should the polkit file be patched so that it lists the executable as something else

@dtzWill
Copy link
Member

dtzWill commented Apr 1, 2019

Please add an entry for this in nixos/module-list.nix otherwise the NixOS module isn't available for use! :)

@dtzWill
Copy link
Member

dtzWill commented Apr 1, 2019

And it looks like 1.4.4 is out, so might want to bump to that :).

@alexarice
Copy link
Contributor Author

And it looks like 1.4.4 is out, so might want to bump to that :).

I have bumped up the version number though for some reason I cannot work out it seems to be accepting the old sha256 hash. I don't think it should be doing this as if I purposefully break it then it says it is wrong and that it was expecting a hash which is not the one it is currently using. I've just checked and both hashes work in the derivation. Any idea what is causing this to happen and is it a problem @dtzWill

@alexarice
Copy link
Contributor Author

I believe my above observation was due to caching on my laptop, it is now fixed.

@alexarice
Copy link
Contributor Author

@dtzWill @jtojnar @symphorien is there anything else I need to do for this to be merged?

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

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

I would ask that you please rewrite the git history as it has become rather difficult to follow. The first commit should be simply adding yourself to the maintainer list. After that you can probably lump all other changes into a single commit.

nixos/modules/hardware/brillo.nix Outdated Show resolved Hide resolved
pkgs/os-specific/linux/brillo/default.nix Outdated Show resolved Hide resolved
pkgs/os-specific/linux/brillo/default.nix Outdated Show resolved Hide resolved
@alexarice
Copy link
Contributor Author

I've made the changes you suggested and I think I've managed to rebase everything @aanderse though can't see how to mark as resolved

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

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

👍 LGTM
@jtojnar & @symphorien are you two satisfied to merge?

@symphorien
Copy link
Member

LGTM :)

@alexarice alexarice force-pushed the master branch 2 times, most recently from 0fbf0ef to 5d53e3b Compare April 14, 2019 22:20
@aanderse
Copy link
Member

@alexarice I'm testing this out on a laptop but can't seem to get anything to happen...
brillo -L lists intel_backlight, but when I run any of the commands nothing seems to happen. Do you have a set of test commands you used that I can try?

@alexarice
Copy link
Contributor Author

alexarice commented Apr 15, 2019

brillo -A 0.5 and brillo -U 0.5 works for me. Do you get an error message or does nothing happen? I have also just realised I've been running wayland and haven't tested it on X
Edit: -G (get current brightness) -G -m (get maximum brightness) and -G -c (get minimum brightness) also work for me
Edit2: Could you also check your user is part of the video group and could you try brillo -A 0.5 -v 1 to turn on some error messages
Final Edit: pkexec /nix/store/48bg34xxcrqvizn026r5hvldd50dpcrh-brillo-1.4.4/bin/brillo -A 5 also works even when my user is not part of the video group though it would be a lot nicer if I didn't have to specify the full path for this to work
Actual final edit: I could patch the polkit file to not need the full path

@aanderse
Copy link
Member

@alexarice I made a mistake and it turns out running pkexec brillo -A 0.5 does work. If I run the command unprivileged (though my user has been added to the video group, logged out and back in), the command does not work and gives the following error:

brillo -A 0.5 -v 1
!ERR: src/file.c:191    file_read():    fopen: No such file or directory: '/home/andersea/.cache/brillo/backlight.intel_backlight.mincap'
!ERR: src/file.c:161    file_open():    open: Permission denied: '/sys/class/backlight/intel_backlight/brightness'
!ERR: src/main.c:24     main(): Execution failed

@alexarice
Copy link
Contributor Author

Interesting, I've done a bit of investigation and I think the following is happening:

  • I believe you are getting a permission denied as you don't have services.udev.packages = [ brillo ]; in your configuration.nix. This should be set by the module but I don't know of a way to test modules without rebuilding my configuration off my local nixpkgs
  • I looked at what was happening on mine and if I delete the file that doesn't exist on yours then It throws an error but works anyway
  • I had set that file using brillo -rc -S 1 but I had done this on 1.4.3 where it worked correctly
  • I now have an error about failing to write to that file when running the same command
  • If I manually do 'echo 1 >> backlight.intel_backlight.mincap` Then everything works correctly.
  • The code throwing the error has changed from 1.4.3 to 1.4.4, Maybe this is an upstream bug?

@alexarice
Copy link
Contributor Author

I have looked over the code and believe there could be an upstream error, should I revert this to 1.4.3 and submit an issue there?

@alexarice
Copy link
Contributor Author

I have had a bit more of an investigate and have submitted a merge request upstream, though I believe at the moment the only functionality which doesn't work is the minimum brightness setting and this can be manually set

@aanderse
Copy link
Member

* I believe you are getting a permission denied as you don't have `services.udev.packages = [ brillo ];` in your `configuration.nix`. This should be set by the module but I don't know of a way to test modules without rebuilding my configuration off my local nixpkgs

I installed the brillo module that you have here. I also tried bumping the version down to 1.4.3 and same error.

brillo -A 0.5 -v 1
!ERR: src/file.c:192    file_read():    fopen: No such file or directory: '/home/andersea/.cache/brillo/backlight.intel_backlight.mincap'
!ERR: src/file.c:163    file_open():    open: Permission denied: '/sys/class/backlight/intel_backlight/brightness'
!ERR: src/main.c:27     main(): Execution failed

I feel like I'm doing something wrong?

@dtzWill
Copy link
Member

dtzWill commented Apr 17, 2019 via email

@alexarice
Copy link
Contributor Author

That is very strange, I just built my system against this fork with nixos-rebuild -I ~/nixpkgs switch and added only hardware.brillo.enable = true and I get the following output:

brillo -A 5 -v 1 
!ERR: src/file.c:191	file_read():	fopen: No such file or directory: '/home/alex/.cache/brillo/backlight.intel_backlight.mincap'

But my screen gets brighter.

For the error above I am trying to get a fix upstream https://gitlab.com/cameronnemo/brillo/merge_requests/4

@alexarice
Copy link
Contributor Author

Upstream issues have been fixed and I have moved this to 1.4.6.
@aanderse did you every figure out what was giving you permission errors?

@aanderse
Copy link
Member

It looks like you might want to nudge upstream on that 1.4.6 release...

~> brillo -V
brillo 1.4.5

https://gitlab.com/cameronnemo/brillo/blob/v1.4.6/src/light.h#L8

The issue persists. I have to assume I'm doing something wrong at this point. As a KDE user I don't actually need this program... so I'm going to leave it up to someone else to say whether the program works or not. It would be nice if at least one person other than @alexarice could confirm this works under X11 as expected.

@alexarice
Copy link
Contributor Author

Did you try if the program light works for you as that has near identical module definition. Have asked for the version to be bumped upstream

@aanderse
Copy link
Member

Did you try if the program light works for you as that has near identical module definition. Have asked for the version to be bumped upstream

@alexarice I have not and as I mentioned at this point I'm happy if someone else can confirm.

@alexarice alexarice changed the title brillo: init at 1.4.3 brillo: init at 1.4.8 Aug 28, 2019
@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-may-2019/3032/48

@FRidh FRidh merged commit 6661154 into NixOS:master Nov 3, 2019
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

9 participants